Solving a nonhomogeneous differential equation by POWER SERIES - AGAIN

I am trying to solve the DE $y''+y=x^2$ using the series expansion method. First, I assume that there exists a solution

$$y=a_0+a_1 x+a_2 x^2+a_3 x^3+a_4 x^4+a_5x^5+...$$

$$\therefore y'=0+a_1 +2a_2 x+3a_3 x^2+4a_4x^3+5a_5x^4...$$

$$\therefore y''=0+0 +2a_2 +6a_3 x+12a_4x^2+20a_5x^3...$$

Substituting into the DE,

$$(2a_2 +6a_3 x+12a_4x^2+20a_5x^3+...)+(a_0+a_1 x+a_2 x^2+a_3 x^3+a_4 x^4+...)=x^2$$

and then equating coefficients of like-powers,

$$x^0\Rightarrow2a_2+a_0=0$$ $$x^1\Rightarrow6a_3+a_1=0$$ $$x^2\Rightarrow12a_4+a_2=1$$ $$x^3\Rightarrow20a_5+a_3=0$$

So then solving for the recursion relations, given that the RHS isn't $x^2$ but $0$ instead, a very simple Maclaurin series appears, giving $\sin x$ and $\cos x$. But it isn't $0$. There's a discontinuity in the pattern because a random 1 comes out from the $x^2$ term. Previously someone told me that $x^2-2$ is a solution as well, which makes the final solution

$$y=c_1\cos x + c_2\sin x +x^2-2$$

Which is correct. Could someone tell me how this $x^2-2$ can be found from that pattern? I am trying to do this problem using the power series method, so only answers showing how to solve it using THAT method are appreciated. I know how to do it using variation of parameters or undetermined coefficients.

So, how can one do it using the power series?

First note that for all odd $n$, $$a_{n+2}=-\frac{a_n}{(n+2)(n+1)}$$ so for all $p\ge1$, (by intuition and recurrence) : $$a_{2p+1}=\frac{(-1)^p}{(2p+1)!}a_1$$ which gives you the $x\mapsto a_1\sin x$ solution for the equation with zero second member.
Now for even $n$, $n=2p$, you can either find a similar closed form for $a_n$, or first solve the homogeneous equation, finding $$a_{2p}=\frac{(-1)^p}{(2p)!}a_0$$ which gives the solution $x\mapsto a_0\cos x$, and then find a lonely solution for the equation with second member $x\mapsto x^2$.
To accomplish this, note that the equation is linear, of second order, with constant coefficients, and the second member is an exponential-polynom (the product of an exponential, here $x\mapsto e^{0t}$, by a polynomial, here $x\mapsto x^2$). The theory tells you there is a polynomial solution, which you can pick in polynomials of same degree than $x\mapsto x^2$. Hence the $x\mapsto x^2-2$ solution, which is easy to find when you know where to look.
To go the other way, you can for example express all the even coefficients in terms of $a_2-1$, which gives you for all $p\ge1$ : $$a_{2p}=\frac{2(-1)^{p-1}}{(2p)!}(a_2-1)\text{ and } a_0=-2(a_2-1)-2$$ If you want to come back to everything expressed in terms of $a_0$ and $a_1$, just substitute.