Example 4 For each $n \in \mathbf{N}^{*}$, solve the equation
$$
\sin x \sin 2 x \cdots \sin n x+\cos x \cos 2 x \cdots \cos n x=1 .
$$
When $n=1$, then $\sin x + \cos x = 1$. Also, $\sin x + \cos x = \sqrt{2} \cos \left(x - \frac{\pi}{4}\right)$, so $x = 2m\pi$ or $2k\pi + \frac{\pi}{2}$, where $m, k \in \mathbf{Z}$.

When $n=2$, then $1 = \sin x \sin 2x + \cos x \cos 2x = \cos (2x - x) = \cos x$, so $x = 2m\pi$, where $m \in \mathbf{Z}$.

When $n > 2$, then $1 = \sin x \sin 2x \cdots \sin nx + \cos x \cos 2x \cdots \cos nx \leqslant |\sin x \sin 2x \cdots \sin nx| + |\cos x \cos 2x \cdots \cos nx| \leqslant |\sin x \sin 2x| + |\cos x \cos 2x| = \max \{|\sin x \sin 2x + \cos x \cos 2x|, |\sin x \sin 2x - \cos x \cos 2x|\} = \max \{|\cos x|, |\cos 3x|\}$. Therefore, if some $x$ is a solution to the original equation, then $|\cos 3x| = 1$ or $|\cos x| = 1$. If $|\cos 3x| = 1$, then $\sin 3x = 0$, so $\cos x \cos 2x \cdots \cos nx = 1$. Still, $|\cos x| = 1$, so we only need to consider the case where $|\cos x| = 1$. After verification, when $n > 2$, $x = 2m\pi$, where $m \in \mathbf{Z}$, satisfies the original equation. If $x = (2k + 1)\pi$, where $k \in \mathbf{Z}$, then $\sin rx = 0$, $\cos rx = (-1)^r$, for $r = 1, 2, \cdots, n$, so $1 = \sin x \sin 2x \cdots \sin nx + \cos x \cos 2x \cdots \cos nx = (-1)^{\frac{n(n+1)}{2}}$. Therefore, when $\frac{n(n+1)}{2}$ is even, $x = (2k + 1)\pi$ satisfies the original equation, but this happens only when $n$ or $n+1$ is divisible by 4, making $\frac{n(n+1)}{2}$ even.

Thus, the final answer is: when $n=1$, then $x = 2m\pi$ or $x = 2k\pi + \frac{\pi}{2}$, where $m, k \in \mathbf{Z}$; when $n = 4l - 2$ or $n = 4l + 1$, where $l \in \mathbf{N}^{*}$, then $x = 2m\pi$, where $m \in \mathbf{Z}$; when $n = 4l$ or $n = 4l - 1$, where $l \in \mathbf{N}^{*}$, then $x = m\pi$, where $m \in \mathbf{Z}$.