Solution (source code)

= Solution

Multiply the original equation on the left by $A^{-1}$ to obtain
$$
B=A+I+A^{-1}.
$$
Each term on the right commutes with $A$. Thus
$$
\boxed{BA=A^2+A+I=AB.}
$$
No general commutativity of <matrix multiplication> is being assumed; it follows from this particular expression for $B$.