Here's a graph of the antiderivative $F(x)$:

You can see the function is periodic and discontinuous. In particular it'll have jumps at $\pm \pi, \pm 3 \pi, \pm 5 \pi$, etc since those are the points where $\tan(\frac x 2)$ jumps from $+ \infty$ to $- \infty$.
The second part of the F.T.C. includes a requirement that $F$ must be continuous on the interval we care about. That means you can't just plug in $0$ and $2 \pi$, since those are not in the same "continuous segment" of $F$. Another way of saying this is: $F$ is not a valid antiderivative of $f$ on any interval that contains one of these discontinuities.
Instead, once you see where $F$ is continuous, you could rewrite your integral as $\int_{-\pi}^{\pi} f(x) dx$ (using the fact that your integrand is periodic) and then evaluate as
$$\lim_{x \to \pi^-} F(x) - \lim_{x \to -\pi^+} F(x) = \left( \frac \pi 4 \right) - \left( - \frac \pi 4 \right) = \frac \pi 2$$
which is the correct value for this definite integral.
If you don't want to use the "periodicity trick", then an alternate strategy is to "break the integral up into chunks so $F$ is continuous on each chunk".
$$
\begin{align}
\int_0^{2 \pi} f(x) dx &= \int_{0}^\pi f(x) dx + \int_\pi ^{2 \pi} f(x) dx \\
&= \left[\lim_{x \to 0^-} F(x) - \lim_{x \to -\pi^+} F(x) \right]
+ \left[\lim_{x \to \pi^-} F(x) - \lim_{x \to 0^+} F(x) \right] \\
&= \left[ \frac \pi 4 - 0 \right] + \left[ 0 - \left(-\frac \pi 4\right) \right] \\
&= \frac \pi 2.
\end{align}
$$
This takes a couple of extra steps, but it's also more straightforward: you don't need to rely on noticing $f$ is periodic, you just need to know where $F$ is discontinuous.