Most of your work is correct. You just need to organize your calculations.
You write \(\displaystyle a_n\) when you actually are calculating \(\displaystyle a_0\). You write \(\displaystyle b_n\) when you are calculating \(\displaystyle a_n\) and in the same time you write \(\displaystyle b_n\) when you are calculating \(\displaystyle b_n\).
You calculated \(\displaystyle a_n\) as \(\displaystyle +\frac{4}{n^2\pi^2}\) when it should be \(\displaystyle -\frac{4}{n^2\pi^2}\) for \(\displaystyle n=1,3,5,\cdots\)
You say \(\displaystyle a_0 = 1\) which is correct. You write:
\(\displaystyle f(x) = \frac{a_0}{2} + \cdots \rightarrow\) correct, then you write:
\(\displaystyle f(x) = 1 + \cdots \rightarrow\) wrong.
You should write: \(\displaystyle f(x) = \frac{1}{2} + \cdots\)
Now you know the values of \(\displaystyle a_0, a_n,\) and \(\displaystyle b_n\). Write the general form as:
\(\displaystyle f(x) = \frac{a_0}{2} + \sum_{n=1}^{\infty}a_n\cos\frac{n\pi x}{2} + b_n\sin \frac{n\pi x}{2}\)
Since \(\displaystyle a_n\) takes only odd indices, you can change any \(\displaystyle n\) there to \(\displaystyle 2n-1\). Now replace the coefficients with their values.
\(\displaystyle f(x) = \frac{1}{2} + \sum_{n=1}^{\infty}-\frac{4}{(2n-1)^2\pi^2}\cos\frac{(2n-1)\pi x}{2} + (-1)^n\frac{2}{n\pi}\sin \frac{n\pi x}{2}\)
Now the second term will keep track of the odd indices while the third term will keep track of both odd and even as \(\displaystyle b_n\) takes both.