Why do some trig equations give solutions in terms of roots?

In some optimization problems, I started getting very odd answers, and have traced it back to solutions of the following equation: $$\cos(t)+\tan(t)\sec(t)=0$$

Mathematica tells me that the solution of this equation (for reals between $$-\frac\pi2$$ and $$\frac\pi2$$) is $$2 \arctan(a)$$ where $$a$$ a root of the equation $$-1 - 2 x + 3 x^2 - 4 x^3 - 3 x^4 - 2 x^5 + x^6$$. I'm not super interested in the derivation of this specific solution, but more broadly, how is it that trigonometric equations have solutions in terms of these giant unwieldy polynomials?

Is there a process for deriving said polynomials?

Write your equation in the form $$\cos(t)+\frac{\sin(t)}{\cos^2(t)}=0$$ and then make the substitution: $$\sin(t)=\frac{2t}{1+t^2}$$ $$\cos(t)=\frac{1-t^2}{1+t^2}$$ Then you have to solve $${\frac {-{t}^{2}+1}{{t}^{2}+1}}+2\,{\frac {t}{-{t}^{2}+1}}=0$$ for $$t$$

Any of the six trigonometric functions can be written as a rational function of $$\sin{x}$$ and $$\cos{x}$$. If we have a rational function of $$\sin{x}$$ and $$\cos{x}$$, it can be written as a ratio of polynomials in $$\sin{x}$$ and $$\cos{x}$$. So to solve $$f(\sin{x},\cos{x})=0$$ for a rational function, it suffices to solve $$p(\sin{x},\cos{x})=0$$ for the particular polynomial $$p$$ in the numerator of $$f$$ (in lowest terms, etc.)

But by the tangent half-angle formulae, if $$t=\tan{(x/2)}$$, we have $$\sin{x} = \frac{2t}{1+t^2} , \quad \cos{x} = \frac{1-t^2}{1+t^2},$$ so the solutions are the solutions of $$p\left( \frac{2t}{1+t^2} , \frac{1-t^2}{1+t^2} \right) = 0 .$$ Multiplying this by a power of $$1+t^2$$ then finally gives a polynomial in $$t$$.

For example, the equation you give is $$0 = \cos{t} + \tan{t}\sec{t} = \frac{\cos^2{t}+\sin{t}}{\cos{t}} ,$$ so we want to solve $$0 = \cos^2{t} + \sin{t} .$$ Using the tangent half-angle formulae, $$0 = \frac{(1-t^2)^2}{(1+t^2)^2} + \frac{2t}{1+t^2} = \frac{(1-t^2)^2 + 2t(1+t^2)}{(1+t^2)^2} ,$$ and the numerator should simplify into the polynomial you've given.

It's simpler in this case to rewrite $$\cos^2{t} = 1-\sin^2{t}$$, and then you find that you need to solve $$1 + \sin{t} - \sin^2{t} = 0 ,$$ which is much easier and won't introduce spurious roots.

Short answer is that trig angular relations are themselves ratios of right triangle length of sides ... like $$x = f(\theta)= f(t)$$ say.. in the given example.

So if $$x=\tan \theta= \tan t$$

then $$\cos 2 x = \frac{1-t^2}{1+t^2}$$

etc. and for similar Weierstrass trig relations will define polynomials in a functional polynomial relationship by eliminating of $$\theta$$ or $$t$$, leaving behind polynomials.

To be clear the matter of next obtaining roots of the resulting polynomial is entirely a consequential process.