You make your conclusion basing on the equation and the boundary conditions. The easiest way is to change variables $x'=x+\frac{\pi}{2}$; then $\lambda_n=n^2$ and $X_n(x')=\cos (nx')$ from the standard problem; returning to old coordinates

\begin{equation}

X_n(x)=\cos (nx+\frac{\pi 2}{2})=\left\{\begin{aligned}

&(-1)^m \cos (2mx) && n=2m,\\

&(-1)^{m+1}\sin ((2m+1)x) && n=2m+1.

\end{aligned}\right.

\end{equation}

We can drop sign at our wish. So, you got correctly only half of the eigenfunctions, but in this particular problem it would lead to a correct solution. Indeed, since "initial" functions $x^2$ and $0$ are even only $\cos(2mx)$ would be in the end. However, it will cost you points!

If we observe that the functions $x^2$ and $0$ are even, and thus solution must be even, we can reduce interval to $(0,\frac{\pi}{2})$ and set conditions $u_{x=0}=u_{x=\pi/2}=0$ which would lead to $\lambda_m=4m^2$ and $X_m=\cos (2mx)$ from the beginning.