A little integration paradox
(This is an expansion of my earlier comment.)
Consider the function
$$f_c(x)=\frac{x}{\sqrt 2}-\frac1{\sqrt 2}\arctan\left(\frac{\sin\,2x}{3+2\sqrt{2}+\cos\,2x}\right)$$
You can check that the derivative of $f_c(x)$ is $\dfrac1{1+\cos^2 x}$. The relevance of this function is that $f_c(x)$, unlike the function $f(x)=\dfrac1{\sqrt 2}\arctan\left(\dfrac{\tan\,x}{\sqrt 2}\right)$ given in the OP, has no discontinuities within the integration interval $[0,2\pi]$:
Thus,
$$\int_0^{2\pi}\frac{\mathrm dx}{1+\cos^2 x}=\left.\frac{x}{\sqrt 2}-\frac1{\sqrt 2}\arctan\left(\frac{\sin\,2x}{3+2\sqrt{2}+\cos\,2x}\right)\right|_0^{2\pi}=\pi\sqrt 2$$
One wonders how the two functions $f(x)$ and $f_c(x)$ could look so different and yet have the same derivative. A plot of $f_c(x)-f(x)$ shows the difference:
Here, we see that the two functions differ not by a constant, but by a piecewise constant function (i.e., a step function). In fact, the Fundamental Theorem of the Calculus can be stated a bit more generally than is usual in textbooks. To quote Oleksandr Pavlyk's blog entry on this subject,
Every calculus student knows that antiderivatives can contain an arbitrary additive constant. But in fact, there’s more arbitrariness than that: one can add different constants on different parts of the interval.
As already mentioned in the previous answers, the trouble lies in the use of the Weierstrass substitution; the source of the problem, simply put, is that the substitution function used happens to be discontinuous within the interval of integration. Thus, to properly evaluate definite integrals of rational functions of sine and cosine, one has to be careful in using the Weierstrass substitution, and must pay attention to the behavior near the singularities.
Jeffrey and Rich, in their paper, discuss methods for computer algebra systems to cope with this particular weakness of the Weierstrass substitution.
For the sake of completeness, here's a general formula for an antiderivative of $\dfrac1{p+q\cos^2 x}$ that is continuous over the real line:
$$\int\frac{\mathrm dx}{p+q\cos^2 x}=\frac1{\sqrt{p(p+q)}}\left(x-\arctan\left(\frac{q\sin\,2x}{2p+q+2\sqrt{p(p+q)}+q\cos\,2x}\right)\right)$$
If $\tan(y)=a\tan(x)$, then $\tan(y-x)=\frac{(a-1)\tan(x)}{1+a\tan^2(x)}$, and therefore, $$ y=x+\tan^{-1}\left(\frac{(a-1)\tan(x)}{1+a\tan^2(x)}\right)\tag{1} $$ Since $\left|\frac{(a-1)\tan(x)}{1+a\tan^2(x)}\right|\le\frac{\left|a-1\right|}{2\sqrt{a}}$, $(1)$ is a nice continuous function of $x$.
In this question, $a=\frac1{\sqrt2}$, so we get $$ \int\frac{\mathrm{d}x}{1+\cos^2(x)}=\frac{x-\tan^{-1}\left(\frac{(\sqrt2-1)\tan(x)}{\sqrt2+\tan^2(x)}\right)}{\sqrt2}\tag{2} $$
An unusual substitution, the "$\tan(z/2)$"substitution, is being done here. You must take a careful look at what you are integrating. Here is a reference on this substitution.