Example 1 Fill the numbers $1,2,3, \cdots, n$ into $n$ cells labeled $1,2,3, \cdots, n$, with one number per cell. How many ways are there to fill the cells so that the number in each cell matches its label?
Let $a_{n}$ be the number of valid ways. Add the number $n+1$ and the cell labeled $n+1$.

For each valid way in $a_{n}$, we move the number in the $k$-th cell to the $n+1$-th cell, and fill $n+1$ into the $k$-th cell, obtaining $n a_{n}$ valid ways;

For the $n$ numbers, if the $k$-th cell is filled with $k (1 \leqslant k \leqslant n)$, the other $n-1$ numbers have $a_{n-1}$ valid ways. We also move the number in the $k$-th cell to the $n+1$-th cell, and fill $n+1$ into the $k$-th cell, obtaining $n a_{n-1}$ valid ways.
Thus, there are $a_{n+1}=n a_{n}+n a_{n-1}$ ways.
It is easy to see that $a_{1}=0, a_{2}=1$.
Let $a_{n}=n!b_{n}$, then $(n+1) b_{n+1}=n b_{n}+b_{n-1}$,

i.e., $b_{n+\mathrm{i}}-b_{n}=-\frac{1}{n+1}\left(b_{n} \cdots b_{n-1}\right)$,
$$
\begin{array}{l}
\prod_{k=1}^{n-1}\left(b_{i+1}-b_{k}\right) \\
=\prod_{k=1}^{n-1}\left[-\frac{1}{k+1}\left(b_{k}-b_{k-1}\right)\right] . \\
\therefore b_{n}-b_{n-1}=(-1)^{n-2} \frac{2}{n!}\left(b_{2}-b_{1}\right) \\
=(-1)^{n} \frac{1}{n!} . \\
\text { Then } \sum_{i=1}^{n}\left(b_{i}-b_{i-1}\right)=\sum_{i=1}^{n}(-1)^{i} \frac{1}{i!} . \\
\therefore b_{n}=\sum_{i=1}^{n}(-1)^{i} \frac{1}{i!} .
\end{array}
$$

Thus, $a_{n}=n!\sum_{i=1}^{n}(-1)^{i} \frac{1}{i!}$ is the desired result.