I cannot figure out why the latter answer is the correct answer
Let $A$ and $B$ be square matrices: apply $ABA$=$B^2$ so the following is certain: (pick one)
If $A$ is invertible then so is $B$
If $B$ is invertible then so is $A$
On
More fundamentally, if $X$ is the inverse of $B$, then $(X^2AB)A=X^2B^2=I$. Therefore $A^{-1}=X^2AB$. This proof can be modified to work on a monoid, so that if $aba=b^2$ and $bx=xb=1$, we can prove that $a$ has both a left inverse $y$ and a right inverse $z$ and in turn, $y=z$ is the inverse of $a$.
Assume $B$ is invertible, than $B^2$ is invertible and from the equation so is $ABA$.
The rest follows as a consequence of multiplication of invertible matrices