Example 3 Find the sum $S_{n}=1^{2}+2^{2}+\cdots+n^{2}$.
The geometric meaning of the sum $S_{n}$ is the $n$-layer stacking of a unit cube, which, when mapped onto a plane, results in a table of $n$ square numbers represented by 1, arranged in a stepped shape:
\begin{tabular}{ccccccc}
1 & & & & & \\
1 & 1 & & & & \\
1 & 1 & &. & & \\
1 & 1 & 1 & & & \\
1 & 1 & 1 & & & \\
1 & 1 & 1 & & & \\
$\cdots$ & $\cdots$ & $\cdots$ & $\cdots$ & & \\
1 & 1 & 1 & $\cdots$ & $\cdots$ & 1 \\
1 & 1 & 1 & $\cdots$ & $\cdots$ & 1 \\
$\cdots$ & $\cdots$ & $\cdots$ & $\cdots$ & $\cdots$ & $\cdots$ \\
1 & 1 & 1 & $\cdots$ & $\cdots$ & 1
\end{tabular}

Completing the table into a rectangular table with a width of $n$ columns and a length of $1+2+$ $\cdots+n$ rows, the number of 1s is $n \cdot \frac{n(n+1)}{2}$.
The number of 1s in the rectangular table can also be expressed as
$$
\begin{aligned}
S_{n} & +1+(1+2)+(1+2+3)+\cdots \\
& +[1+2+\cdots+(n-1)] \\
= & S_{n}+\frac{1^{2}-1}{2}+\frac{2^{2}-2}{2}+\cdots+\frac{n^{2}-n}{2} \\
= & \frac{3}{2} S_{n}-\frac{n(n+1)}{4} .
\end{aligned}
$$
(Note: The 1s outside of $S_{n}$ are counted by column from left to right)
Thus, $\frac{n^{2}(n+1)}{2}=\frac{3}{2} S_{n}-\frac{n(n+1)}{4}$.
Therefore, $S_{n}=\frac{1}{6} n(n+1)(2 n+1)$.