These integrals come from a section in a PDE book on the Fourier integral representation.
But I'm going to use contour integration to evaluate the first one.First notice that the singularities at $x=1$ and $x=-1$ are removable.
$$ \int_{0}^{\infty} \frac{\cos (\frac{\pi x}{2}) \cos(ax)}{1-x^{2}} \ dx = \frac{1}{2} \int_{-\infty}^{\infty} \frac{\cos (\frac{\pi x}{2}) \cos(ax)}{1-x^{2}} \ dx = \frac{1}{4} \int_{-\infty}^{\infty} \frac{\cos[(a-\frac{\pi}{2})x] + \cos[(a+\frac{\pi}{2})x]}{1-x^{2}} \ dx$$
$$ = \frac{1}{4} \text{Re} \ \text{PV} \int_{-\infty}^{\infty} \frac{e^{i(a-\frac{\pi}{2})x} + e^{i(a+\frac{\pi}{2})x}}{1-x^{2}} \ dx = \frac{1}{4} \text{Re} \ \text{PV} \int_{-\infty}^{\infty} \frac{e^{i(a-\frac{\pi}{2})x}}{1-x^{2}} \ dx + \frac{1}{4} \text{Re} \ \text{PV} \int_{-\infty}^{\infty} \frac{e^{i(a+\frac{\pi}{2})x}}{1-x^{2}} \ dx $$
If $|a| < \frac{\pi}{2}$,
$$ \text{PV} \int_{-\infty}^{\infty} \frac{e^{i(a-\frac{\pi}{2})x}}{1-x^{2}} \ dx = - i \pi \text{Res}\Big[ \frac{e^{i(a-\frac{\pi}{2})x}}{1-x^{2}}, -1 \Big] - i \pi \text{Res}\Big[ \frac{e^{i(a-\frac{\pi}{2})x}}{1-x^{2}} ,1 \Big]$$
$$ = \frac{i \pi}{2} \Big(-e^{-i(a- \frac{\pi}{2})} + e^{i(a- \frac{\pi}{2})} \Big) = - \pi \sin \Big(a - \frac{\pi}{2} \Big) = \pi \cos a$$
where I have integrated around an indented semicircle in the lower half plane.And
$$ \text{PV} \int_{-\infty}^{\infty} \frac{e^{i(a+\frac{\pi}{2})x}}{1-x^{2}} \ dx = i \pi \text{Res}\Big[ \frac{e^{i(a+\frac{\pi}{2})x}}{1-x^{2}}, -1 \Big] + i \pi \text{Res}\Big[ \frac{e^{i(a+\frac{\pi}{2})x}}{1-x^{2}} ,1 \Big] $$$$= \frac{i \pi}{2} \Big( e^{-i(a+ \frac{\pi}{2})} - e^{i(a+ \frac{\pi}{2})} \Big) = \pi \sin\Big(a + \frac{\pi}{2} \Big) = \pi \cos a$$
where I have integrated around an indented semicircle in the upper half plane.So if $|a| \le \frac{\pi}{2}$,
$$\int_{0}^{\infty} \frac{\cos (\frac{\pi x}{2}) \cos(ax)}{1-x^{2}} \ dx = \frac{1}{4} \text{Re} \ (2 \pi \cos a) = \frac{\pi}{2} \cos a $$For $|a| > \frac{\pi}{2}$ the two integrals will cancel each other.