Why does this series expansion for $\frac{1}{\cos(x)}$ fail using $\frac{1}{1-x}$? I'm trying to do (2nd order) Taylor expansion for 
$$\frac{1}{\cos(x)}$$ using $$\frac{1}{1-x}$$
What I do is write
$$\cos(x)=1-\frac{x^2}{2!}+\frac{x^4}{4!}+ \cdot\cdot\cdot, \text{ at } x_0=0$$
and
$$\frac{1}{1-x}=1+x+x^2+\cdot\cdot\cdot$$
so
$$\frac{1}{\cos(x)}=\frac{1}{1-(1-\cos(x))}=1+(1-\cos(x))+(1-\cos(x))^2$$
$$=1+(1-1+\frac{x^2}{2!})+(1-1+\frac{x^2}{2!})^2$$
$$=1+\frac{1}{2}x^2+\frac{1}{4}x^4$$
which is correct up to order 2 (or order 1?), but the coefficient of $x^4$ (is that 3rd or 4th order?) is wrong.
Why? How can I get the correct coefficients for higher orders?
And if I do want only 2nd order Taylor polynomial, then what is the term $\frac{1}{4}x^4$?

You did not calculate the 3rd and 4th order coefficients like this, only the second (you have some $o(x^2)$ remaining from the first term, of which the $\frac{x^4}{4}$ is a part of).
In order to get the fourth (the third is null by parity), you need all terms that will give a fourth order coefficient, so that you are only left with some $o(x^4)$
In your case, for the fourth coefficient, it would be
$\frac{1}{cos(x)} =  1 + (1-1+\frac{x^2}{2!}-\frac{x^4}{4!} + o(x^4))+(1-1+\frac{x^2}{2!}-\frac{x^4}{4!} + o(x^4))^2$
$= 1 + \frac{x^2}{2!}-\frac{x^4}{4!} + \frac{x^4}{4} + o(x^4) = 1 + \frac{x^2}{2!}+\frac{5x^4}{24} + o(x^4)$
