This may be solved by complex variables. Put $z = e^{i\theta}$ to obtain
$$\int_0^{2\pi} \frac{d\theta}{1-a\cos\theta+a^2} =
\int_{|z|=1} \frac{1}{iz} \frac{dz}{1-a/2(z+1/z)+a^2} =
\int_{|z|=1} \frac{1}{iz} \frac{z dz}{z-a/2(z^2+1)+za^2} \\=
-i \int_{|z|=1} \frac{dz}{z-a/2(z^2+1)+za^2}$$
The two poles (use e.g. the quadratic formula) are at
$$z_{0,1} = \frac{1+a^2}{a} \pm \frac{\sqrt{1+a^2+a^4}}{a}.$$
Now assume that $a>1,$ so that the pole corresponding to the plus sign is clearly outside of the unit circle.
On the other hand $$z_1 =\frac{1+a^2}{a} - \frac{\sqrt{1+a^2+a^4}}{a} < 1$$
because it is equivalent to
$$ 1+a^2 -a < \sqrt{1+a^2+a^4}$$
which is $$ a^4 + 2 a^2(1-a) +(1-a)^2 < 1 + a^2 +a^4
\Leftrightarrow
2a^2 - 2a^3 + (1 - a)^2 < 1 + a^2\\
\Leftrightarrow
2a^2 < 2 a^3 + 2a
\Leftrightarrow a <a^2 + 1,$$
which holds trivially.
Now the residue of the integrand at $z_1$ is given by
$$\lim_{z\to z_1} \frac{1}{1-az+a^2} =
\frac{1}{1+a^2-1-a^2+\sqrt{1+a^2+a^4}} =
\frac{1}{ \sqrt{1+a^2+a^4} }.$$
It follows that the integral is given by
$$2\pi i \times -i \times \frac{1}{ \sqrt{1+a^2+a^4} } =
\frac{2\pi}{ \sqrt{1+a^2+a^4} }.$$