I was practicing for my trig test, and I came across this question $2\cos(x) - \sin(x) = 0$. I tried applying the trig identity $\tan(x) = \frac{\sin(x)}{\cos(x)}$ resulting in the following equation:
$$\cos(x)(2-\tan(x)) = 0$$
Whilst using Wolfram alpha to verify my solution, I found that only the zeros of $2-\tan(x)$ show up in the graph.
I thought that the polynomial $(x - \frac{\pi}{2}) (x - \frac{3\pi}{2})$ from the roots of $\cos(x)$ from $0$ to $2\pi$ should behave in the same way as $\cos(x)$ with $2-\tan(x)$ (and it does).

So my question is why do the roots shift when I multiply by $\tan(x)$ and what I am I doing wrong?
Although each $\pi(n+1/2)$ is a pole for the tangent, $\lim_{x\to\pi(n+1/2)}(x-\pi(n+1/2))\tan(x)=-1$ can be checked.
So although your expression is not defined at $x=\pi/2$ and $x=3\pi/2$, the expression $(x-\pi/2)(2-\tan x)$ tends to $0-(-1)=1$ so the whole thing $(x-\pi/2)(x-3\pi/2)(2-\tan x)\to(\pi/2-3\pi/2)\cdot1=-\pi$.
With similar reasoning you can figure out why the expression does not tend to zero, but rather tends to $\pi$. The roots have shifted intuitively because the zero in the expression $(x-\pi/2)$ cancels with the ‘infinity’ in the $\tan$.
Your original question concerning the solutions to $\cos(x)(2-\tan x)=0$; clearly if $\tan x=2$ we have a solution, but the other possibility for when $\cos x=0$ is subtle - because $\tan$ is not defined at these points! Going back to the original original question of the solutions to $2\cos x-\sin x=0$, you can easily rearrange this to $2=\sin(x)/\cos(x)=\tan(x)$ and it’s clear there are no other solutions. In dividing by $\cos(x)$ you have potentially divided by zero, which is absolutely “not allowed” in algebraic manipulation - hence the error.