characterize all matrices $X$ such that $BA = X$ whenever $AB = X$ It is clear that if $A$ and $B$ are $n\times n$ matrices (over a field) with $AB = I$ then $BA = I$. I like to characterize all matrices $X$ such that $BA = X$ whenever $AB = X$.
If $AB=X$ then we have $BAB=BX$. So $BA=X$ can only follow if $BX=XB$ for all $B$. Therefore $X$ has to be in the center of the general linear group which is all multiples of the identity matrix $I$.
From mathworld.wolfram
"matrix multiplication is not, in general, commutative (although it is commutative if A and B are diagonal and of the same dimension)."

So if for example
$$A=\left(\begin{array}{ccc} 1 &amp; 0 &amp; 0\\ 0 &amp; 2 &amp; 0\\ 0 &amp; 0 &amp; 3 \end{array}\right)$$
and
$$B=\left(\begin{array}{ccc} 4 &amp; 0 &amp; 0\\ 0 &amp; 5 &amp; 0\\ 0 &amp; 0 &amp; 6 \end{array}\right)$$
then 
$$AB=BA=\left(\begin{array}{ccc} 4 &amp; 0 &amp; 0\\ 0 &amp; 10 &amp; 0\\ 0 &amp; 0 &amp; 18 \end{array}\right)$$