Calculating the integral $\int\limits_{0}^{2\pi} \frac{d \theta}{a^2 \sin^2\theta+b^2 \cos^2\theta}$

The substitution is incorrect : the tangent is not bijective on the interval $[0,2\pi]$. First, you need to restrict yourself to an interval on which the tangent behaves better. Using the $\pi$-periodicity of the function you want to integrate, you can show that:

$$\int_0^{2 \pi} \frac{1}{a \sin^2 (\theta)+b \cos^2 (\theta)} d \theta = 2 \int_{-\pi/2}^{\pi/2} \frac{1}{a \sin^2 (\theta)+b \cos^2 (\theta)} d \theta,$$

and go from there.

Note that this is a good warning about using Wolfram (or any formal computation system) : the formula for the indefinite integral is good, but it holds only on each interval $(k\pi -\pi/2, k\pi+\pi/2)$, which the program does not tell you.