Since # has category code 6, it has a very special meaning in TeX, because it is used for denoting parameters in macro definitions.
The rules of TeX tell that when you want to store a # in the replacement text of a macro, you need to double it.
When processing the replacement text for a macro definition, a single # has to be followed by a digit (1 to 9), denoting a pointer to the corresponding argument, whereas ## will be stored as #. This is the trick that allows something like
\def\foo{\def\baz##1{-##1-}}
so the replacement text of \foo is \def\baz#1{-#1-} and a call of \foo will define \baz as a single argument macro.
The primitive \detokenize in the replacement text will do its work when the macro is called and expanded, not at definition time, unless the definition is done with \edef, which will first perform full expansion before storing the replacement text in memory.
Note that when you do \meaning\foo (assuming the above definition), you will be presented with
macro:->\def \baz ##1{-##1-}
and the same will happen with \detokenize that uses the same mechanism. Thus something like
\edef\hashmarks{\detokenize{####}}
will actually see two # in the replacement text, but the final result will be four of them. The standard mechanism when processing \edef will first half the number of # and then \detokenize will double them back. In particular, you can't produce this way an odd number of #.
If you want to produce delimiter lines, it's much better to use an indirect method, making in advance the required token list consisting of # with category code 12. In the example I use three of them, just because it's an odd number.
\documentclass{article}
\begingroup\lccode`?=`# \lowercase{\endgroup
\newcommand{\lineofhashsigns}{???}
}
\newenvironment{delimitedtext}
{\par\lineofhashsigns\par}
{\par\lineofhashsigns\par}
\begin{document}
\begin{delimitedtext}
abc
\end{delimitedtext}
\end{document}

A different definition for \lineofhashsigns that doesn't require \lowercase is by changing the category code:
\catcode`#=12
\newcommand{\lineofhashsigns}{###}
\catcode`#=6
You can add whatever token in the replacement text, so long as you don't want the macro to have arguments.