Let $G$ be an abelian group of finite order, and define $f: G\to G$ by $f(g)=g^2$. I would like to prove that $f$ is an isomporphism if and only if $G$ has an odd order.
I am able to prove that $f$ (defined above) is a homomorphism if and only if $G$ is abelian fairly simply. If $G$ is abelian, then for all $a, b\in G$, $$f(ab)=(ab)^2=abab=a^2b^2=f(a)f(b)$$ So $f$ is indeed a homomorphism. And if $f$ is a homomorphism, then for all $a, b\in G$, $$f(ab)=f(a)f(b) \implies (ab)^2=a^2b^2 \implies a^{-1}ababb^{-1}=a^{-1}aabbb^{-1}\implies ba=ab$$ Meaning $G$ is abelian.
This proof holds for any (not necessarily finite) group.
Applying this to the original problem, we are now left with proving that $f$ is bijective if and only if $G$'s order is odd. Since $f$ is from a finite $G$ to itself, it will suffice to show that:
$$|G| \space \text{is odd} \iff f \space \text{is injective (or surjective)}$$ But here I am stuck. I believe there is a simple way to finish off the proof, but I can't think of it, and I couldn't find this question asked here before. I appreciate any help.
Suppose $|G|$ is odd. Let $g\in{ker(f)}$, meaning that $g^2=1$. Thus $g=1$ by Lagrange, otherwise $g$ is an element of order 2 in a group of odd order.
Now, suppose $|G|$ is even. Then, $G$ admits an element of order 2, let's say $h\in{G}$. Thus $ker(f)$ isn't trivial, because $h\in{ker(f)}$, meaning that $f$ is not an isomorphism.