Example of a non-abelian group $(G,.)$ where $a^2b=ba^2\Rightarrow ab=ba $
My thought process:
- The relation $a^2b=ba^2$ can be read as stating that $a^2$ is in the centralizer of $b$, or that $b$ is in the centralizer of $a^2$. Can't tell which is more useful, yet.
- The relation $ab=ba$ similarly states that $a$ is in the centralizer of $b$, or that $b$ is in the centralizer of $a$.
- Centralizers of $b$ are involved in both, so the implication can be conveniently rephrased: $$\text{for all $a,b\in G$ we have:}\ a^2\in C_G(b)\implies a\in C_G(b).$$
How to make that implication true in a non-abelian group? Remember that $C_G(b)$ is a subgroup. If it contains the element $a^2$ it will contain all the powers $(a^2)^k=a^{2k}$, $k\in\Bbb{Z}$. Can we make sure that $a$ is among those powers? Yes, we can! Simply insist that for all $a$ we have $a^{2k-1}=1$ for some integer $k$.
Any non-abelian group $G$ of odd order will work. This is because, by Lagrange, every element then has an odd order as well.
See here for an explicit construction of the smallest non-abelian group of odd order.