with texlive 2022 you get
! TeX capacity exceeded, sorry [input stack size=10000].
\protect ->\noexpand \protect
\noexpand
l.9 \end{gather}
! ==> Fatal error occurred, no output PDF file produced!
with texlive 2021
! TeX capacity exceeded, sorry [input stack size=5000].
\restore@math@cr ->\def \math@cr@@@
{\cr }
l.9 \end{gather}
! ==> Fatal error occurred, no output PDF file produced!
With 2020 you get the error you show
! Use of \math@cr@@ doesn't match its definition.
\new@ifnextchar ...ved@d = #1\def \reserved@a {#2}
\def \reserved@b {#3}\futu...
l.9 \end{gather}
?
With the current texlive 2022 you can use \protect
. That also worked in 2021, but not the older texlive 2020 release.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather}
p+q=w \\
a+b=c \label{eq:1} \tag{$\protect\substack{a\\a}$}
\end{gather}
\eqref{eq:1}
\end{document}