(going to the fifth term for an example purpose)
Using the basic expansions of cos(x) gives us
$$
\frac{1}{\cos(x)} = \frac{1}{1-\frac{x^2}{2}+\frac{x^4}{24} + \cdots}
$$
of the form $ \frac{1}{1-X} $ which has a known and easy expansion :
$$
1+X+X^2+X^3+X^4+X^5+\cdots
$$
where $ X = \frac{x^2}{2} + \frac{x^4}{24} $ (approching $0$ when $x$ approaches $0$). The smaller $x$ term is $x^2$, so we don't need to take more terms than $X^2$ in the above expansion (otherwise terms would exceed $x^5$ and be negligeable).
Hence,
$$
\frac{1}{\cos(x)} = 1+(\frac{x^2}{2}−\frac{x^4}{24})+(\frac{x^2}{2})^2+o_{x\to0}(x^5)
$$
$$
= 1+\frac{x^2}{2}+\frac{5x^4}{24}
$$