I am trying to find the Fourier coefs of even extension of $cos^2(\pi x /L)$ which is defined over $0\leq x \leq L$.
So since the function is even it only has $a_0$ and $a_n$ as cosine series expansion. I find $a_0$ to be 0.5 which is fine, but when I find $a_n$ I come to zero, which does not make sense and I do not know what I am doing wrong.
Basically, I write
$a_n=\frac{1}{2L} \int_{-L}^{L} cos^2(\pi x /L) cos(n\pi x/L)$
even I put this in a software to calculate the integral, I got similar to the one I found by hand, which has all sine terms which at $\pm L$ give zero so that's why I come to zero values for $a_n$.
I don't see what I doing wrong
I think you're overcomplicating it. $$\cos^2 (\pi x / L ) = \frac 1 2 (1 + \cos (2\pi x / L) )$$ by familiar double angle formulae.
By the way, could there be a typo in the question? "An even extension of $\cos^2(\pi x / L)$ on $[0,L]$" is just $\cos^2(\pi x / L)$, right?