The integrand has poles at $x=\pm ib$ and singularities on the real axis at $x=(2n+1)\frac{\pi}{2}$ with cuts where the tangent becomes negative. Nevertheless, the integral can be viewed as a complex contour in the upper half-plane with the segment $(-\infty,\infty)$ shifted slightly by $+i0$ to avoid the singularities and make the integrand holomorphic in the upper half-plane except at $x=ib$. Let
$$C_R=(-R,R) \cup \gamma_R$$
be the closed contour where $\gamma_R$ is the large semi-circle counter-clockwise in the upper half-plane of radius $R$ s.t. $R\neq (2n+1)\frac{\pi}{2}$. Since the tangent is bounded on $\gamma_R$, the integral over the arc $\gamma_R$ vanishes in the limit $R \rightarrow \infty$. Using the residue theorem for the limiting closed contour $C_\infty$, we arrive at
$$\frac{\pi}{b} \, \tan^a(ib) = \int_{C_\infty} \frac{\tan^a(x)}{x^2+b^2} \, {\rm d}x = \int_{-\infty+i0}^{\infty+i0} \frac{\tan^a(x)}{x^2+b^2} \, {\rm d}x = (e^{i\pi a}+1) \int_0^{\infty} \frac{|\tan(x)|^a}{x^2+b^2} \, {\rm d}x \,. \tag{1}$$
Rearranging gives the desired result.
Technically the last step is a bit more intricate than it appears at first sight. When substituting $x\rightarrow -x$ for the segment $(-\infty+i0,i0)$, it becomes $(-i0,\infty-i0)$ which matters because it changes the phase of the tangent. When $\tan(x)$ becomes negative, it has phase $+\pi$ for $\Im(x)>0$ and $-\pi$ for $\Im(x)<0$. This can be seen for e.g. $x\in(-\pi/2+i0,i0)$ and the fact that for $x$ close to $0$, $\tan(x) \approx x$ and hence they share the same phase properties i.e. $$\arg(\tan(x))=\arg(x)=\arg(-1+i0)=\arg(e^{i\pi})=\pi$$ and by the periodicity this translates to $\mathbb{R}$.
Therefore the correct sequence of steps leading to the RHS of (1) is as follows:
$$\int_{i0}^{\infty+i0} \frac{\tan^a(x)}{x^2+b^2} \, {\rm d}x + \int_{-i0}^{\infty-i0} \frac{(-\tan(x))^a}{x^2+b^2} \, {\rm d}x \\
=\sum_{n=0}^\infty \int_{n\pi + i0}^{n\pi +\pi/2+i0} \frac{\tan^a(x)}{x^2+b^2} \, {\rm d}x + \sum_{n=0}^\infty \int_{n\pi + \pi/2 + i0}^{n\pi + \pi+i0} \frac{\tan^a(x)}{x^2+b^2} \, {\rm d}x \\
+ \sum_{n=0}^\infty \int_{n\pi - i0}^{n\pi +\pi/2 - i0} \frac{(-\tan(x))^a}{x^2+b^2} \, {\rm d}x + \sum_{n=0}^\infty \int_{n\pi + \pi/2 - i0}^{n\pi +\pi - i0} \frac{(-\tan(x))^a}{x^2+b^2} \, {\rm d}x \, .$$
The argument inside $(\dots)^a$ of the first and last term is positive (on this part of the decomposed domain), i.e. the integrand has phase $0$ and both terms can be combined to $\int_0^\infty \frac{|\tan(x)|^a}{x^2+b^2} \, {\rm d}x$. The second term has $\Im(x)>0$ and thus phase $+\pi$. Likewise in the third term $\Im(x)<0$ and hence $-\tan(x)$ has phase $+\pi$ also. Pulling out the phase and using absolute values instead, these two terms combine to $e^{i\pi a} \int_0^\infty \frac{|\tan(x)|^a}{x^2+b^2} \, {\rm d}x$
giving the RHS of (1).