Factorize the expression
$$
x^{3}+x^{2}-a^{2} x+\left(a^{2}+a\right) \text {. }
$$
Let $f(x)=x^{3}+x^{2}-a^{2} x+\left(a^{2}+a\right)$. This is a cubic polynomial, which needs to be factored into linear factors. Suppose $g(x)=x+p$ is such a factor (where $p$ may depend on $a$), then $g(0)=p, f(0)=a^{2}+a$, so $p$ must divide $a^{2}+a=a(a+1)$, and $g(1)=1+p$ must divide $f(1)=2+a$. Therefore, the possible values of $g(0)$ and $g(1)$ are:
$$
\begin{array}{l}
g(0): \pm 1, \pm a, \pm(a+1), \pm a(a+1), \\
g(1): \pm 1, \pm(a+2) .
\end{array}
$$

Since $g(1)-g(0)=1$, among the various combinations of these values, only one pair is worth considering, which is $g(0)=a+1, g(1)=a+2$, which means $g(x)=x+a+1$. After trial division,
$$
\begin{array}{l}
x^{3}+x^{2}-a^{2} x+\left(a^{2}+a\right) \\
=(x+a+1)\left(x^{2}-a x+a\right) .
\end{array}
$$

Another solution: Consider the original expression as a polynomial in $a$, $F'(a)=a^{2}(1-x)+a+x^{2}(1-x)$, which is a quadratic polynomial. Using the quadratic formula, we find its two roots to be $a_{1}=-(x+1), a_{2}=\frac{-x^{2}}{1-x}$. Therefore, the linear factors of $F(a)$ are $a+x+1$ and $(1-x) a+x^{2}$. From this, it is not difficult to derive the result of the previous solution.