Update
biblatex v3.17 uses a new approach to deal with the required "initialisation" in auxiliary files that means that biblatex no longer writes lines of its own to those files.
See https://github.com/plk/biblatex/issues/1116 and https://github.com/plk/biblatex/pull/1166 as well as https://github.com/josephwright/siunitx/issues/408 for some background.
This should keep aux files much more predictable when biblatex is involved.
With v3.17 and above the .toc file will look as desired
\contentsline {chapter}{Contents}{i}{}%
\contentsline {chapter}{\chapternumberline {1}Chap}{1}{}%
\contentsline {section}{\numberline {1.1}Test}{1}{}%
\contentsline {subsection}{Test}{1}{}%
Old answer
tl;dr
biblatex produces the \defcounter{refsection} lines in the .toc to be able to correctly pick up refsection membership for citations in chapter/section/... headings in the the ToC. The relevant patch to \addtocontents can be removed without negative effects if you (i) don't use refsections or (ii) don't cite in chapter/section/... headings.
I'll first explain a way to undo biblatex's patch to \addtocontents that adds this \defcounter command and we can then look at an example that shows why this patch is necessary.
biblatex patches \addtocontents in an \AtEndPreamble hook, so if we want to undo the patch one possibility is to hook into \AtEndPreamble before biblatex to save the original definition of \addtocontents and then again after biblatex has done its thing to restore the definition.
Written compactly this might look like
\makeatletter
\usepackage{etoolbox}
\AtEndPreamble{\let\murray@saved@addtocontents\addtocontents}
\usepackage[backend=biber, style=numeric, sorting=none]{biblatex}
\AtEndPreamble{\let\addtocontents\murray@saved@addtocontents}
\makeatother
Then following MWE demonstrates the need for the patch
\documentclass{memoir}
\makeatletter
\usepackage{etoolbox}
\AtEndPreamble{\let\murray@saved@addtocontents\addtocontents}
\usepackage[backend=biber, style=numeric, sorting=none]{biblatex}
\AtEndPreamble{\let\addtocontents\murray@saved@addtocontents}
\makeatother
\addbibresource{biblatex-examples.bib}
\usepackage{kantlipsum}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\begin{refsection}
\chapter{Chap}
\kant[1] \autocite{sigfridsson,worman}
\section{Test \autocite{sigfridsson}}
\kant[1]
\subsection{Test}
\kant[1]
\printbibliography
\end{refsection}
\begin{refsection}
\chapter{Chap}
\kant[1] \autocite{geer,sigfridsson}
\section{Test \autocite{sigfridsson}}
\kant[1]
\subsection{Test}
\kant[1]
\printbibliography
\end{refsection}
%\autocite{geer,nussbaum,sigfridsson}
\end{document}
produces

The patch becomes important if your document contains different refsections. refsections are kept completely separated from each other and each contain their own citations and bibliography. When you then cite an entry in chapter/section/... title and that title goes to the ToC, the citation is not in the original refsection any more (the ToC need not be printed in the same refsection as the original citation: indeed this will rarely be the case in per-chapter refsections) and biblatex does not know where the citation belongs. In this example that means that biblatex simply gives up.
If you uncomment the \autocite{geer,nussbaum,sigfridsson} at the end, you see another bad effect. The citation number in the ToC is "[3]", but in the section headings the numbers are "[1]" and "[2]".
![Citations are [3] in ToC.](../../images/d873b743452780633402769c128d8587.webp)
The effect might be slightly less pronounced in other set-ups, but whenever your document contains several refsections and you cite something in a chapter/section/... heading, the patch is necessary to make sure the citations come out correctly in the ToC.
biblatex is not the only package that inserts context information into the .toc file.
Take the following babel example (also alluded to by cfr in the comments)
\documentclass{article}
\usepackage{xcolor}
\usepackage[british,dutch,naustrian,ngerman]{babel}
\def\month{1}% we need january where German German and Austrian German differ
\begin{document}
\tableofcontents
\begin{otherlanguage}{british}
\section{\protect\today}
\end{otherlanguage}
\section{\protect\today}
\begin{otherlanguage}{naustrian}
\section{\protect\textcolor{red}{\protect\today}}
\end{otherlanguage}
\begin{otherlanguage}{dutch}
\section{\protect\today}
\end{otherlanguage}
\end{document}

To be able to correctly identify the language and with it the expected date format in each heading, babel adds language information to the .toc
\babel@toc {ngerman}{}
\babel@toc {british}{}
\contentsline {section}{\numberline {1}\today }{1}%
\babel@toc {ngerman}{}
\contentsline {section}{\numberline {2}\today }{1}%
\babel@toc {naustrian}{}
\contentsline {section}{\numberline {3}\textcolor {red}{\today }}{1}%
\babel@toc {ngerman}{}
\babel@toc {dutch}{}
\contentsline {section}{\numberline {4}\today }{1}%
\babel@toc {ngerman}{}
polyglossia does the same, but the .toc looks even more complex (tested with the upcoming polyglossia version v1.45, because earlier versions would not do enough here, see https://github.com/reutenauer/polyglossia/issues/205).
\selectlanguage *{german}
\bgroup
\selectlanguage *{english}
\contentsline {section}{\numberline {1}\today }{1}%
\egroup
\selectlanguage *{german}
\contentsline {section}{\numberline {2}\today }{1}%
\bgroup
\selectlanguage *[variant=austrian]{german}
\contentsline {section}{\numberline {3}\textcolor {red}{\today }}{1}%
\egroup
\selectlanguage *{german}
\bgroup
\selectlanguage *{dutch}
\contentsline {section}{\numberline {4}\today }{1}%
\egroup
\selectlanguage *{german}
So you can't really rely on your .toc file to contain only \contentsline lines with nothing in between.
It gets even worse for your murderer from memoir + biblatex + 2 TOCs error. Compare the .toc of
\documentclass{memoir}
\usepackage{kantlipsum}
%\usepackage{hyperref}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{Chap}
\kant[1]
\section{Test}
\kant[1]
\subsection{Test}
\kant[1]
\chapter{Chap}
\kant[1]
\section{Test}
\kant[1]
\subsection{Test}
\kant[1]
\end{document}
without hyperref
\contentsline {chapter}{Contents}{i}%
\contentsline {chapter}{\chapternumberline {1}Chap}{1}%
\contentsline {section}{\numberline {1.1}Test}{1}%
\contentsline {subsection}{Test}{1}%
\contentsline {chapter}{\chapternumberline {2}Chap}{3}%
\contentsline {section}{\numberline {2.1}Test}{3}%
\contentsline {subsection}{Test}{3}%
to the .toc with hyperref
\contentsline {chapter}{Contents}{i}{section*.1}%
\contentsline {chapter}{\chapternumberline {1}Chap}{1}{chapter.1}%
\contentsline {section}{\numberline {1.1}Test}{1}{section.1.1}%
\contentsline {subsection}{Test}{1}{section*.2}%
\contentsline {chapter}{\chapternumberline {2}Chap}{3}{chapter.2}%
\contentsline {section}{\numberline {2.1}Test}{3}{section.2.1}%
\contentsline {subsection}{Test}{3}{section*.3}%
The number of arguments to \contentsline changes! This means you can't even be sure how many arguments to gobble if you don't know if hyperref is loaded or not.
.toc. The code you're trying to use looks inherently fragile to me. All kinds of things will screw it up. (If you think Biblatex is bad, you should see what babel does to my.tocs. At least Biblatex only adds its thing once per entry. There are also situations in which you might want to write additional stuff to the.tocwithout needing to worry about this. – cfr Oct 25 '19 at 03:07