\underbrace and align environment

You need first of all to make the \underbrace a math relation, for spacing; but you also have to extend the space reserved to it, because an underbrace has a minimum width:

\documentclass{report}

\usepackage{amsmath} % Mathe
\usepackage{mathtools} % Mathe
\usepackage{amsfonts} % Mathesymbole
\usepackage{calc}

\newcommand{\ueq}[1][]{%
  \if\relax\detokenize{#1}\relax
    \sbox0{$\underbrace{=}_{}$}%
    \mathrel{\mathmakebox[\wd0]{=}}
  \else
    \mathrel{\underbrace{=}_{\mathclap{#1}}}
  \fi}

\begin{document}

\begin{align*}
    D(D^TD)^{-1} &\ueq[D=B(B^TB)^{-1}] B(B^TB)^{-1}((B(B^TB)^{-1})^TB(B^TB)^{-1})^{-1} \\
      &\ueq B(B^TB)^{-1}(((B^TB)^{-1})^TB^TB(B^TB)^{-1})^{-1}
\end{align*}

\end{document}

So, if \ueq has no optional argument it produces an equal sign as wide as an underbraced one, otherwise it adds the underbrace.

enter image description here


Here is an alternative to what you want, which still conveys the same information without decorating equals signs with equations. The traditional way to annotate steps in a derivation is with labels. So you could instead do

\documentclass{report}

\usepackage{amsmath} % Mathe
\usepackage{mathtools} % Mathe
\usepackage{amsfonts} % Mathesymbole

\begin{document}
\begin{align}
    D(D^TD)^{-1} 
      &= B(B^TB)^{-1}((B(B^TB)^{-1})^TB(B^TB)^{-1})^{-1}  \label{subst}\\
      &= B(B^TB)^{-1}(((B^TB)^{-1})^TB^TB(B^TB)^{-1})^{-1} \label{trans}
\end{align}
Here \eqref{subst} is due to the substitution $D=B(B^TB)^{-1}$, and \eqref{trans} is by the transpose law for matrix multiplication.
\end{document}

sample code output