Mapping to Square is Endomorphism iff Abelian

Theorem
Let $\left({G, \circ}\right)$ be a group.

Let $\phi: G \to G$ be defined such that $\forall g \in G: \phi \left({g}\right) = g \circ g$.

Then $\left({G, \circ}\right)$ is abelian $\phi$ is (group) endomorphism.

Necessary Condition
Let $\left({G, \circ}\right)$ be an abelian group.

Let $a, b \in G$ be arbitrary.

Then:

As $a$ and $b$ are arbitrary, the above holds for all $a, b \in G$.

Thus $\phi$ is a group homomorphism from $G$ to $G$.

So by definition, $\phi$ is a group endomorphism.

Sufficient Condition
Let $\phi: G \to G$ as defined above be a group endomorphism.

Then:

Thus, by definition, $G$ is an abelian group.