Extraneous solutions without performing squaring operation 
Solve in $[0, 2\pi]$ $$\sec x+\tan x=2\cos x$$

My mind boggled while solving the trigonometric equation in two different ways:
Method $1.$
Assuming $x\ne \frac{\pi}{2},\frac{3\pi}{2}$
We have:
$$\sec x+\tan x=2\cos x$$
$\implies$
$$\sec x-\tan x=\frac{1}{2\cos x}$$
Adding both we get
$$2\sec x=2\cos x+\frac{1}{2\cos x}$$
$\implies$
$$\frac{3}{2\cos x}=2\cos x$$
$\implies$
$$\cos x=\frac{\pm \sqrt{3}}{2}$$
which gives four solutions in $[0,2\pi]$ which are $\frac{\pi}{6},\frac{11\pi}{6},\frac{5\pi}{6},\frac{7\pi}{6}$ but only two of them which are $\frac{\pi}{6}, \frac{5\pi}{6}$ satisfying the original equation.
Method $2.$
Writing the given equation as
$$\frac{1}{\cos x}+\frac{\sin x}{\cos x}=2\cos x $$
Then we get
$$1+\sin x=2(1-\sin^2 x)$$
$\implies$
$$2\sin^2 x+\sin x-1=0$$
$\implies$
$$\sin x=-1, \sin x=\frac{1}{2}$$
Since $x\ne \frac{\pi}{2},\frac{3\pi}{2}$ we can ignore $\sin x=-1$. Thus we have
$\sin x=\frac{1}{2}$ which gives the two solutions $\frac{\pi}{6}, \frac{5\pi}{6}$
My question is why am i getting two extraneous solutions in Method $1$ even though they are in the domain of $\sec x$ and $\tan x$?

Hint
Subtract the two equation to find $$2\tan x=2\cos x-\dfrac1{2\cos x}$$
As $\cos x\ne0,$
multiply out both sides by $2\cos x,$ to find $$4\sin x=4\cos^2x-1=4(1-\sin^2x)-1$$
Your solution needs to satisfy this equation as well
