I am trying to prove that $(ab)^2=a^2b^2$ doesn't hold for a semigroup $S$. It is easy to prove(using inverse property) that the above condition holds for an abelian group. However, for semigroup, it doesn't hold. Is it because that the inverse element doesn't exist in $S$? How to prove formally?
Edit: I found the above question in an undergraduate book. I think that it should have been stated as
Give a counter example to show that $(ab)^2=a^2b^2$ doesn't necessarily hold in a semigroup.
The answer is as stated by Arthur and Thomas in the comments.
In fact, it doesn't even have to be true in a group. If we take $S_3$ as our group and take $a$ as (12) and $b$ as (123), then this doesn't hold.