Showing $(ab)^n=a^nb^n$ given $(ab)^2=a^2b^2$. This is part of Exercise 2.1.15 of F. M. Goodman's "Algebra: Abstract and Concrete".

Let $G$ be a group. Suppose $(ab)^2=a^2b^2$ for all $a, b\in G$. Show that $(ab)^n=a^nb^n$ for all $a, b\in G$, $n\in\mathbb{N}$.

My Attempt:
I'm using induction on $n$. Let $a, b\in G$.
Obviously $(ab)^1=ab=a^1b^1$ so the result holds for $n=1$.
Assume $(ab)^r=a^rb^r$ for some $r\in\mathbb{N}$.
Consider when $n=r+1$: we have
$$\begin{align}
(ab)^{r+1}&=(ab)^rab \\
&=a^rb^rab \\
&=a^{r+1}a^{-1}b^rab,
\end{align}$$ but I don't know where to go from here.

Since $abab=aabb$ you can get $ba=ab$, that is $a,b$ commute. Now you can rearrange any product between them.
