Given two square matrices $A$ and $B$, is $(AB)^2 = A^2B^2$ true or false? I tried with a counter example and it came out that this claim is false.
I took a matrix 
$$
  A=
  \left[ {\begin{array}{cc}
   2 & 1\\
   3 & 2\\
  \end{array} } \right]
$$ 
and a matrix
$$
  B=
  \left[ {\begin{array}{cc}
   1 & 3\\
   4 & 1\\
  \end{array} } \right].
$$
I first calculated $$AB$$
and I got:
$$
  AB=
  \left[ {\begin{array}{cc}
   6 & 7\\
   11 & 11\\
  \end{array} } \right]
$$
and then I calculated $$AB \times AB$$ that is same as $$(AB)^2$$
and I got:
$$
  (AB)^2=
  \left[ {\begin{array}{cc}
   85 & 119\\
   187 & 198\\
  \end{array} } \right]
$$    
then I calculated $$A \times A$$ that is the same as $$A^2$$ and I got
$$
  A^2=
  \left[ {\begin{array}{cc}
   7 & 4\\
   12 & 13\\
  \end{array} } \right]
$$ 
and after I calculated $$B^2$$
$$
  B^2=
  \left[ {\begin{array}{cc}
   13 & 6\\
   8 & 13\\
  \end{array} } \right]
$$ 
and at the end I calculated $$A^2B^2$$ and I got:
$$
  A^2B^2=
  \left[ {\begin{array}{cc}
   123 & 94\\
   250 & 241\\
  \end{array} } \right]
$$ 
so I am deducing that the claim at the beginning is false, so
$$(AB)^2 \neq A^2B^2$$
Is this right?

In general, $AB \neq BA$, so $(AB)^2 = ABAB = A(BA)B \neq A(AB)B = A^2B^2.$
