If the cosine function is periodic, why does it have a Fourier Transform?
Indeed there are two things you have to know.

First, it can be shown that the continuous-time Fourier transform can be obtained from the continuous-time Fourier series by letting the period $T$ go to infinity. 

Second, formally speaking the Fourier transform integral for periodic signals do not converge, hence do not exist. The solution is a generalisation of the Fourier transform by the use of Dirac impulse functions. 

The result is an interpretation that the Fourier transform of periodic functions is a sum of scaled Dirac impulses at the Fourier harmonic frequencies, and the scale being the corresponding Fourier series coefficients.