Missing calculations of the coefficient and the sign is wrong in the end.
Solution
Separating variables $u(x,t)=X(x)T(t)$ we get
\begin{align}
&X''+\lambda X=0,\label{3-5}\\
&X(0)=X(\pi)=0,\label{3-6}\\
&T''+(\lambda+4) T=0.\label{3-7}
\end{align}
Problem (\ref{3-5})--(\ref{3-6}) has solution
$$
\lambda_n= n^2,\qquad X_n =\sin (nx),\qquad n=1,2,\ldots$$
and therefore
$$
T_n = A_n \cos ((n^2+4)^{1/2}t)+B_n ((n^2+4)^{1/2}t),$$
and $$
u =\sum_{n=1}^\infty \Bigl[A_n \cos ((n^2+4)^{1/2}t)+B_n ((n^2+4)^{1/2}t)\Bigr]\sin (nx).
$$
Plugging to (\ref{3-3})--(\ref{3-4}) we get
\begin{align*}
&\sum_{n=1}^\infty A_n \sin (nx)=0,\\
&\sum_{n=1}^\infty (n^2+4)^{1/2} B_n \sin(nx)= x^2-\pi x.
\end{align*}
and therefore $A_n=0$,
\begin{multline*}
(n^2+4)^{1/2} B_n = \frac{2}{\pi} \int_0^\pi (x^2-\pi x) \sin (nx)\,dx=\\
-\frac{2}{\pi n}\int_0^\pi (x^2-\pi x)\,d\cos (nx) =\frac{2}{\pi n}\int_0^\pi (2x-\pi)\cos (nx)\,dx=
\\
\frac{2}{\pi n^2}\int_0^\pi (2x-\pi)\,d\sin (nx)=-\frac{4}{\pi n^2}\int_0^\pi \sin (nx)\,dx =\\
\frac{4}{\pi n^3}\cos(nx)\bigl|_{x=0}^{x=\pi}=\left\{\begin{aligned}
&0 &&n=2m,\\
-&\frac{8}{\pi (2m+1)^3} &&n=2m+1.
\end{aligned}\right.
\end{multline*}
Then
\begin{equation*}
u(x,t)=-\sum_{m=0}^\infty \frac{8}{(2m+1)^3 \pi\sqrt{(2m+1)^2+4}} \sin((2m+1)x)\sin(\sqrt{(2m+1)^2+4}t).
\end{equation*}
General comment
Typical errors:
* $\sin(\sqrt{n^2{\color{red}-}4} t)$, $\sin(n t)$ and other errors in $T_n(t)$
* Errors in the calculation of $\int_0^\pi (x^2-\pi x) \sin(nx)\,dx$. It is calculated by integration by parts and it is easier not to break it into two, since function $g(x)$ vanishes at $0$ and $\pi$.
* In the end there is one solution, not two separate solutions for even and odd $n$.