Example 5 Let $x_{1}=a \cdot x_{2}=1$, and
$$
x_{n+2}=\frac{x_{n-1}^{2}-5}{x_{n}}\left(n \in \mathbf{N}^{*}\right) .
$$

Find the value of $a$ for which $\left\{x_{n}\right\}$ is a periodic sequence with a period of 4.
Solution: Clearly, $a \neq 0$. Thus, from the given conditions, we have
$$
\begin{array}{l}
x_{3}=\frac{1-5}{a}=-\frac{4}{a}, \\
x_{4}=\frac{\left(-\frac{4}{a}\right)^{2}-5}{1}=\frac{16}{a^{2}}-5,
\end{array}
$$

Since $\left\{x_{n}\right\}$ has a period of 4, we have $a_{0}=a_{1}=a$, which means
$$
a=\frac{x_{1}^{2}-5}{x_{3}},\left(\frac{16}{a^{2}}-5\right)^{2}-5=a x_{3}=-4 .
$$

Solving this, we get $a=-2$ or 2 or $-\frac{2}{3} \sqrt{6}$ or $\frac{2}{3} \sqrt{6}$.
Explanation: The conclusion of this problem can be generalized to the following general case:
Suppose the sequence $\left\{x_{n}\right\}$ satisfies $x_{1}=a, x_{2}=b$, and
$$
x_{n+2}=\frac{x_{n-1}^{2}+c}{x_{n}}(n \in \mathbf{N}),
$$

then the sequence $\left\{x_{n}\right\}$ is a periodic sequence if and only if: there exist positive integers $k$ and $m$, satisfying $k<m$, such that
$$
\begin{array}{c}
\sin \frac{2 k \pi}{m} \neq 0, \\
\frac{a^{2}+b^{2}+c}{a b}=2 \cos \frac{2 k \pi}{m} .
\end{array}
$$

In this case, one period of the sequence is $m$.