This question have already been asked on this site, but i could not understand the details so i ask it again. Also what i have done is that first for $n=1$ its trivial, for $n=2$ we have $a(ba)b=a(ab)b $. Since $ab=ba$ is given in problem. Does that make it true for $n=2$?
For $n=3$: $ababab=aaabbb$ then i get $baba=aabb$.
How do i prove it for $n=3$?
You ought to start earlier with $(ab)(ab)=a(b(ab))=a(a(bb)=(aa)(bb)$ as required.
Then by induction $(aa)(bb)(ab)=(aa)b(b(ab))=(aa)b(a(bb))=(aa)a(b(bb))=(aaa)(bbb)$ and so on.