Your analysis is correct, overlay means that the bounding box gets not increased, but is essential for adding annotations to nodes that have been created before. However, one can measure how much the annotation overshoots the original matrix, and add the corresponding horizontal space.
You seem to be using an older version of nicematrix. Here is something that adds the required horizontal space after the first matrix. Analogous methods can be used for the newer versions, too. Since this is only a proof of principle I did not make an effort in avoiding global macros, the more so since this will become much easier with the next version of pgf.
\documentclass[10pt, a4paper]{article}
\usepackage{mathtools}
\usepackage{nicematrix}
\usepackage{tikz}
\usetikzlibrary{calc,tikzmark}
\makeatletter% from https://tex.stackexchange.com/a/548004
\ExplSyntaxOn
\NewDocumentCommand \WhenNotMeasuring { } { \legacy_if:nF {measuring@} }
\makeatother
\ExplSyntaxOff
\makeatother
\begin{document}
\begin{align*}
\begin{pNiceMatrix}[name=mymatrix]
1 & 1 & 1 & 1 & 1 \\
2 & 2 & 2 & 2 & 2 \\
3 & 3 & 3 & 3 & 3 \\
4 & 4 & 4 & 4 & 4 \\
5 & 5 & 5 & 5 & 5 \\
\end{pNiceMatrix}\tikzmark{R1}
\WhenNotMeasuring
{\begin{tikzpicture}[remember picture, overlay]
\begin{scope}[local bounding box=annot]
\draw (mymatrix-1-5) -- ++(5em,0) |- (mymatrix-2-5);
\end{scope}
\path let \p1=($(pic cs:R1)-(annot.west)$),
\p2=($(annot.east)-(annot.west)$)
in \pgfextra{\xdef\myshift{\the\dimexpr\x2-\x1}};
\end{tikzpicture}
\hspace{\myshift}}
\rightarrow
\begin{pNiceMatrix}
1 & 1 & 1 & 1 & 1 \\
2 & 2 & 2 & 2 & 2 \\
3 & 3 & 3 & 3 & 3 \\
4 & 4 & 4 & 4 & 4 \\
5 & 5 & 5 & 5 & 5 \\
\end{pNiceMatrix}
\end{align*}
\begin{align}
\begin{pNiceMatrix}[name=myothermatrix]
1 & 1 & 1 & 1 & 1 \
2 & 2 & 2 & 2 & 2 \
3 & 3 & 3 & 3 & 3 \
4 & 4 & 4 & 4 & 4 \
5 & 5 & 5 & 5 & 5 \
\end{pNiceMatrix}\tikzmark{R2}
\WhenNotMeasuring
{\begin{tikzpicture}[remember picture, overlay]
\begin{scope}[local bounding box=annot]
\draw (myothermatrix-1-5) -- ++(5em,0) |- (myothermatrix-2-5)
node[pos=0.25,right]{$a$};
\end{scope}
\path let \p1=($(pic cs:R2)-(annot.west)$),
\p2=($(annot.east)-(annot.west)$)
in \pgfextra{\xdef\myshift{\the\dimexpr\x2-\x1}};
\end{tikzpicture}
\hspace{\myshift}}
\rightarrow
\begin{pNiceMatrix}
1 & 1 & 1 & 1 & 1 \
2 & 2 & 2 & 2 & 2 \
3 & 3 & 3 & 3 & 3 \
4 & 4 & 4 & 4 & 4 \
5 & 5 & 5 & 5 & 5 \
\end{pNiceMatrix}
\end{align}
\end{document}

overlaymeans that the bounding box gets not increased, but is essential for adding annotations to nodes that have been created before. So, in short, you will to have to devise a different strategy if you want to make the annotation part of the matrix. However, is seems to me that you do not even want to do that, rather you seem to want to shift the second matrix far enough to the right. Is this correct? – Jun 14 '20 at 23:10