(Previous steps are omitted.)
By convergence of Fourier series, we have $$ \frac{\pi}{4}+\sum_{n=1}^{\infty}\frac{(-1)^n-1}{\pi n^2}(-1)^n=\frac{\pi}{2} $$
Then how come we can get this from the above formula: $$ \sum_{n=1}^{\infty}\frac{1}{(2n-1)^2}=\frac{\pi^2}{8} $$?
Note that the $n^{th}$ term of the series is zero for even $n$, so you can replace $n$ by $2n-1$ (which gives you all the odd values):
$$\sum_{n=1}^{\infty}\frac{-2}{\pi (2n-1)^2}(-1)^{(2n-1)}=\frac{\pi}{4}$$
And because $(-1)^{(2n-1)}=-1$, multiplying both sides by $\pi/2$ gives the final result.