Example 7 Find all non-zero real-coefficient polynomials $f(x)$ that satisfy $f\left(x^{2}\right)=f^{2}(x)$.
Analysis Using the method of undetermined coefficients, compare the coefficients of the same powers of $x$ on both sides of the equation $f\left(x^{2}\right)=f^{2}(x)$.
Solution Let the polynomial we seek be $f(x)=a_{n} x^{n}+a_{n-1} x^{n-1}+\cdots+a_{1} x+a_{0}$, where $a_{n} \neq 0(n \in \mathbf{N})$. Below, we will prove: $a_{n-1}=\cdots=a_{1}=a_{0}=0$.

Assume that $a_{i}(i=0,1, \cdots, n-1)$ are not all zero, and let $k<n$ be the largest index such that $a_{k} \neq 0$. From $f\left(x^{2}\right) = f^{2}(x)$, we get $a_{n} x^{2 n}+a_{k} x^{2 k}+\cdots+a_{1} x^{2}+a_{0}=\left(a_{n} x^{n}+a_{k} x^{k}+\cdots+a_{1} x+a_{0}\right)^{2}$. By comparing the coefficients of $x^{n+k}$, we obtain $0=2 a_{n} a_{k}$, which contradicts $a_{n} \neq 0, a_{k} \neq 0$. Therefore, our assertion is correct, i.e., $f(x)=a_{n} x^{n}$.
Furthermore, from $f\left(x^{2}\right)=f^{2}(x)$, we know that $a_{n}=1$, hence $f(x)=x^{n}(n \in \mathbf{N})$ is the solution.