This follows from the identities
$$A_1^{-1}=UA_1U^{-1},\;\;A_2^{-1}=UA_2U^{-1},$$
with
$$U=U^{-1}=\left(
\begin{array}{cccc}
 0 & 1 & 0 & 0 \\
 1 & 0 & 0 & 0 \\
 0 & 0 & 0 & 1 \\
 0 & 0 & 1 & 0 \\
\end{array}
\right).$$