
\documentclass{article}
  \usepackage{amsmath}
  \usepackage{cancel}
  \pagestyle{empty}

\begin{document}
\begin{align*}
(a-b)(a+b) &= a^2 + \cancel{ab} - \cancel{ba} - b^2   \\ 
           &= a^2 + \bcancel{ab} - \bcancel{ba} - b^2 \\
           &= a^2 + \xcancel{ab} - \xcancel{ba} - b^2 \\
           &= a^2 + \xcancel{ab - ba} - b^2           \\
           &= a^2 + \cancelto{0}{ab - ba} - b^2       \\
           &= a^2 - b^2
\end{align*}
\end{document}
