Suppose G is a group with x and y as elements. Show that $(xy)^2 = x^2 y^2$ if and only if x and y commute.
My very basic thought is that we expand such that $xxyy = xxyy$, then multiply each side by $x^{-1}$ and $y^{-1}$, such that $x^{-1} y^{-1} xxyy = xxyy x^{-1}$ , and therefore $xy=xy$.
I realize that this looks like a disproportionate amount of work for such a simple step, but that is what past instruction has looked like and that is perhaps why I am confused. Moreover, "if and only if" clauses have always been tricky for me since I took Foundations of Math years ago, but if I remember correctly, the goal here should be to basically do the proof from right to left and then left to right, so to speak. Anyhow, I think that I am overthinking this problem.
Hint
$$(xy)^2=x^2y^2\iff xyxy=xxyy\iff x^{-1}xyxy=x^{-1}xxyy\iff yxy=xyy.$$
Can you finish?