Example 6 Solve the equation:
$$
x=\left(x^{2}+3 x-2\right)^{2}+3\left(x^{2}+3 x-2\right)-2 \text{. }
$$
Let $y=x^{2}+3 x-2$.
Then the original equation becomes
$$
x=y^{2}+3 y-2 \text {. }
$$
(1) - (2) gives $(x-y)(x+y+4)=0$.

Therefore, $x-y=0$ or $x+y+4=0$.
From $x-y=0 \Rightarrow y=x$.
Substituting into (1) yields
$$
\begin{array}{l}
x_{1}=-1+\sqrt{3}, x_{2}=-1-\sqrt{3} . \\
\text { From } x+y+4=0 \Rightarrow y=-x-4 .
\end{array}
$$

Substituting into (1) yields
$$
x_{3}=-2+\sqrt{2}, x_{4}=-2-\sqrt{2} \text {. }
$$

Therefore, the solutions to the original equation are $-1 \pm \sqrt{3},-2 \pm \sqrt{2}$.