Proof (groups of order 4)

By Lagrange's theorem, every non-trivial element in $G$ has order 2 or 4.

If there exists $g\in G$ where $o(g) = 4$, then $\langle g\rangle \leq G$ while $|\langle g\rangle| = 4 = |G|$, so $G=\langle g\rangle \cong C_4$.

Otherwise, we can find distinct $a,b\in G$ with $o(a) = o(b) = 2$. Checking the hypothesis of the direct product theorem,

Therefore $G\cong\gen a\times\gen b\cong C_2 \times C_2$.