Example 2 Let $x \in \mathbf{R}$, try to find the minimum value of the function $f(x)=\left(x^{2}+4 x+5\right)\left(x^{2}+4 x+2\right)+2 x^{2}+8 x+1$.
Let $u=x^{2}+4 x$, then
$$
f(x)=g(u)=(u+5)(u+2)+2 u+1=u^{2}+9 u+11 \text {. }
$$

By the properties of quadratic functions, when $u=-\frac{9}{2}$, $g(u)$ reaches its minimum value, and when $u>-\frac{9}{2}$, $g(u)$ is a strictly increasing function of $u$. Since $u=x^{2}+4 x=(x+2)^{2}-4$, we know that $u \geqslant-4$, and when $x=-2$, $u=-4$. Therefore, when $x=-2$, $f(x)$ reaches its minimum value, which is -9.