This question already has an answer here:
The following is perhaps one of most simple proofs:
Pair up if possible each element of $\;G\;$ with its inverse, and observe that
$$g^2\neq e\iff g\neq g^{-1}\iff \;\text{there exists the pair}\;\;(g, g^{-1})$$
Now, there is one element that has no pairing: the unit $\;e\;$ (since indeed $\;e=e^{-1}\iff e^2=e$), so since the number of elements of $\;G\;$ is even there must be at least one element more, say $\;e\neq a\in G\;$ , without a pairing, and thus $\;a=a^{-1}\iff a^2=e\;$
This is not a strict proof, but you may find it helpful when you want proof without Lagrange’s theorem:
We have that for every $g\in G$ there a unique $g^{-1} \in G$ such that $gg^{-1}=e$.
If you suppose that there is no $a \in G$ such that $a^2=e$, so that $a=a^{-1}$ (i.e. there is no self-inverse element), then for every $x\neq e$ in $G$ we can assign unique $y\in G$ such that $xy=e$. So the set of pairs of elements that are inverses to each other form a partition for $G$.
But then $|G|$ is odd since $e$ is only self-inverse element.