$$
\cos^2 nx=\frac{1+\cos 2nx}{2},
$$
and hence
$$
\int_{-\pi}^\pi f(x)\,\cos^2 nx\,dx=\frac{1}{2}\int_{-\pi}^\pi f(x)\,dx+
\frac{1}{2}\int_{-\pi}^\pi f(x)\,\cos 2nx\,dx
$$
The second integral tends to zero due to Riemann-Lebesgue Lemma, and hence
$$
\lim_{n\to\infty}\int_{-\pi}^\pi f(x)\,\cos^2 nx\,dx=\frac{1}{2}\int_{-\pi}^\pi f(x)\,dx.
$$
$$ \cos^2 nx=\frac{1+\cos 2nx}{2}, $$ and hence $$ \int_{-\pi}^\pi f(x)\,\cos^2 nx\,dx=\frac{1}{2}\int_{-\pi}^\pi f(x)\,dx+ \frac{1}{2}\int_{-\pi}^\pi f(x)\,\cos 2nx\,dx $$ The second integral tends to zero due to Riemann-Lebesgue Lemma, and hence $$ \lim_{n\to\infty}\int_{-\pi}^\pi f(x)\,\cos^2 nx\,dx=\frac{1}{2}\int_{-\pi}^\pi f(x)\,dx. $$