If $ab=ba$, Prove $a^2$ commutes with $b^2$
Solution 1:
Here is the proof (it only uses that $ab=ba$, which is given):
$$\begin{align} a^2b^2 &=aabb = a(ab)b \\ &= a(ba)b = (ab)(ab) \\ &= (ba)(ba) = b(ab)a \\ &= b(ba)a =bbaa\\ &=b^2a^2 \end{align}$$
Solution 2:
Well, let's be explicit on everything, including the associativity (i.e. using parentheses everywhere). We have $$\begin{align} a^2 b^2 &= (aa)(bb) && \text{definition of $x^2$}\\ &= ((aa)b)b && \text{associativity}\\ &= (a(ab))b && \text{associativity}\\ &= (a(ba))b && \text{$a$ and $b$ commute}\\ &= ((ab)a)b && \text{associativity}\\ &= ((ba)a)b && \text{$a$ and $b$ commute}\\ &= (ba)(ab) && \text{associativity}\\ &= (ba)(ba) && \text{$a$ and $b$ commute}\\ &= ((ba)b)a && \text{associativity}\\ &= (b(ab))a && \text{associativity}\\ &= (b(ba))a && \text{$a$ and $b$ commute}\\ &= ((bb)a)a && \text{associativity}\\ &= (bb)(aa) && \text{associativity}\\ &= b^2a^2 && \text{definition of $x^2$} \end{align}$$ Now normally you would not write it this way, because after recognizing that because of associativity it doesn't matter how you set brackets, you usually decide to just omit all brackets, and then a lot of steps (namely all marked with "associativity") don't change anything. Therefore the whole thing collapses into the following sequence, where I in each expression mark red the two items which are exchanged in the following step (i.e. the one which ends up in the innermost parentheses in the detailed derivation above): $$a^2b^2 = a\color{red}{ab}b = \color{red}{ab}ab = ba\color{red}{ab} = b\color{red}{ab}a = bbaa = b^2a^2$$ Now as you can see, that $a$ and $b$ commutes just means that everywhere where $a$ and $b$ are next to each other, you can exchange them.
Also note that at no point I needed to use the inverse; indeed, the only thing I used is associativity (and the presumed property that $a$ and $b$ commute, of course), so the derivation works whenever you have an associative operation, even if you have no group, and in particular no inverses.