Let
$$\begin{equation*}
f(z)=\frac{e^{iaz}}{\left( 1+z^{2}\right) ^{2}}=\frac{e^{iaz}}{
(z-i)^{2}(z+i)^{2}}.
\end{equation*}\tag{1}
$$
The residue of $f(z)$ at $z=i$ is
$$
\begin{eqnarray*}
\underset{z=i}{\mathrm{res}}f(z) &=&\frac{1}{(2-1)!}\lim_{z\rightarrow i}\frac{d}{dz}\left((z-i)^2f(z)\right)\\&=&\lim_{z\rightarrow i}\frac{d}{dz}\left(
\frac{e^{iaz}}{(z+i)^{2}}\right)=\lim_{z\rightarrow i}\frac{
iae^{iaz}(z+i)^{2}-e^{iaz}2\left( z+i\right) }{(z+i)^{4}} \\
&=&-\frac{1}{4}i\left( a+1\right) e^{-a}.
\end{eqnarray*}\tag{2}
$$

Let $C_{R}$ denote the boundary of the upper half of the disk $
\left\vert z\right\vert =R$, described counterclockwise (see picture). By the residue theorem
$$
\begin{eqnarray*}
\int_{-R}^{R}\frac{e^{iax}}{\left( 1+x^{2}\right) ^{2}}dx+\int_{C_{R}}\frac{
e^{iaz}}{\left( 1+z^{2}\right) ^{2}}dz &=&2\pi i \underset{z=i}{\ \mathrm{ res}}
f(z)e^{iaz} \\
&=&\frac{1}{2}\pi \left( a+1\right) e^{-a}.
\end{eqnarray*}\tag{3}
$$
Then
$$
\begin{eqnarray*}
\text{Re}\int_{-R}^{R}\frac{e^{iax}}{\left( 1+x^{2}\right) ^{2}}dx+\text{Re}
\int_{C_{R}}\frac{e^{iaz}}{\left( 1+z^{2}\right) ^{2}}dz &=&\text{Re}\frac{1}{2}\pi \left( a+1\right) e^{-a}, \\ \\
\int_{-R}^{R}\frac{\cos ax}{\left( 1+x^{2}\right) ^{2}}dx+\text{Re}
\int_{C_{R}}\frac{e^{iaz}}{\left( 1+z^{2}\right) ^{2}}dz &=&\frac{1}{2}\pi \left( a+1\right) e^{-a}.
\end{eqnarray*}\tag{4}
$$
When $\left\vert z\right\vert =R$, we have
$$\left\vert \frac{1}{(1+z^{2})^{2}}\right\vert =\frac{1}{\left\vert
z+i\right\vert ^{2}\left\vert z-i\right\vert ^{2}}\leq \frac{1}{\left\vert
\left\vert z\right\vert -|i\right\vert ^{2}\left\vert \left\vert
z\right\vert -\left\vert i\right\vert \right\vert ^{2}}=\frac{1}{(R-1) ^{4}}=:M_R\tag{5},$$
which means that $M_R>0$ and
$$
\begin{equation*}
\lim_{R\rightarrow \infty }M_R= \lim_{R\rightarrow \infty }\frac{1}{(R-1) ^{4}}=0.
\end{equation*}\tag{6}
$$
Then we can apply the Jordan's lemma for every positive constant $a$ and conclude that
$$
\begin{equation*}
\lim_{R\rightarrow \infty }\int_{C_{R}}\frac{e^{iaz}}{\left( 1+z^{2}\right)
^{2}}dz=0.
\end{equation*}\tag{7}
$$
Consequently,
$$
\begin{equation*}
\int_{-\infty }^{\infty }\frac{\cos ax}{\left( 1+x^{2}\right) ^{2}}dx=\frac{1
}{2}\pi \left( a+1\right) e^{-a}
\end{equation*}\tag{8}
$$
and
$$
\begin{equation*}
\int_{0}^{\infty }\frac{\cos ax}{\left( 1+x^{2}\right) ^{2}}dx=\frac{1}{4}
\pi \left( a+1\right) e^{-a}.
\end{equation*}\tag{9}
$$
Note: Exercise 3 on page 265 of Complex Variables and Applications by James Brown and Ruell Churchill generalizes this integral to
$$
\begin{equation*}
\int_{0}^{\infty }\frac{\cos ax}{( b^2+x^{2}) ^{2}}dx=\frac{1}{4b^3}
\pi \left( ab+1\right) e^{-ab}\qquad (a>0,b>0).
\end{equation*}
$$