Each group of order 8 has a subgroup of order 2 and a subgroup of order 4.

Well, you can show that $G$ has a subgroup of order 4 directly. If $G$ has an element of order 4 or 8 then we are already done [why?]

Otherwise let $\pi$ and $\alpha$ be two distinct elements in $G$ of order 2. So $\pi = \pi^{-1}$ and $\alpha = \alpha^{-1}$. Then $\pi\alpha$ must have order 2 as well, lest there be an element of order 4 or 8 which would imply that we are done. This implies that $\pi \alpha = \alpha \pi$. [Indeed, for any elements $a,b,c$ in any group $G'$, if $ab=ac$ then $b$ must equal $c$. But here $(\pi \alpha)(\pi \alpha) = 1$, while $(\pi \alpha)(\alpha \pi) = (\pi \alpha)(\alpha^{-1}\pi^{-1}) = 1$. So indeed, $\pi \alpha = \alpha \pi$.] This implies that $H \doteq \{1,\alpha, \pi, \pi\alpha \}$ is closed under composition, and as every element in $H$ has its inverse in $H$, it follows that $H$ is a subgroup, and has order 4.


If $G$ has no subgroup of order $4$, then every $g\ne e$ has order $2$. Then for any $g,h$, $$ e=(gh)^2=ghgh=ghg^{-1}h^{-1}, $$i.e. $G$ is abelian. Then $\{e,g,h,gh\}$ would be a subgroup of order $4$.


Hint: No group has exactly two elements of order two.

Assume no subgroup of order four exists. Apply Lagrange's Theorem. Apply the hint. See @Mike's answer.

Reference for the lemma that is the hint:

Exercise 4.61 of Gallian's "Contemporary Abstract Algebra (Eighth Edition)"