Let $G$ be a finite group and $\varphi :G \longrightarrow G$ a group homomorphism. To prove:$\DeclareMathOperator{\Ker}{Ker}\DeclareMathOperator{\Im}{Im}$ $$\Ker(\varphi)=\Ker(\varphi^2) \iff \Im(\varphi)=\Im(\varphi^2)$$
I have some tools but I'm not able to combine them effectively. If $x\in \Ker(\varphi)$, then $\varphi(\varphi(x))=\varphi(e_G)=e_G$, hence $\Ker(\varphi) \subseteq \Ker(\varphi^2)$. With the first isomorphism theorem follows $\Im(\varphi) \cong \Im(\varphi^2)$.
Any hints?