baba = aabb, so (ba)^4 = (aabb)(aabb)=(a^2 b^2) (a^2 b^2) = (a^2 b^2)^2 = b^4 a^4=
bbbbaaaa=bb(abab)aa=b (ba)^3 a
So babababa=bbababaa.
Now we multiply this equality by b^-1 on the left and a^-1 on the right, we get
ababab=bababa => (ab)^3 = (ba)^3 hence by injectivity of f we obtain ab=ba so group is commutative.
Note that you must require that f in injective: Take group of nine elements {1, x, y, xx, yy, xy, xxy, xxyy, xyy} with multiplication defined by yx = xyy.