Example 4 Fill the numbers $1,2, \cdots, 8$ into the 8 squares surrounding the four sides of a $3 \times 3$ chessboard, so that the sum of the absolute values of the differences between adjacent numbers in these 8 squares is maximized. Find this maximum value.
Solution: Let the sum of the absolute values of the differences between adjacent numbers in the 8 squares be $M$. Note that rotating the 8 numbers in the outer ring of the $3 \times 3$ chessboard does not change the value of $M$. As shown in Figure 6, let the numbers in each square be denoted as $a_{1}, a_{2}, \cdots, a_{8}$. It is known that $M$ reaches its maximum value when $a_{1}, a_{2}, \cdots, a_{8}$ are arranged in an alternating order of size.

Otherwise, assume that when $M$ is at its maximum, $a_{1}, a_{2}, a_{3}$ are in increasing order, i.e., $a_{1}<a_{2}<a_{3}$. Then, we have:
$$
\begin{array}{l}
M=\left(a_{1}-a_{2}\right)+\left(a_{3}-a_{2}\right)+\left(a_{3}-a_{4}\right)+ \\
\quad \cdots+\left(a_{7}-a_{8}\right)+\left(a_{1}-a_{8}\right) \\
=2\left(a_{1}+a_{3}+a_{5}+a_{7}\right)-2\left(a_{2}+a_{4}+a_{6}+a_{8}\right) .
\end{array}
$$

Among these 8 numbers, if we take $a_{1}, a_{3}, a_{5}, a_{7}$ as the 4 largest numbers and $a_{2}, a_{4}, a_{6}, a_{8}$ as the 4 smallest numbers, then $M$ reaches its maximum value, and $M \leqslant 2 \times(8+7+6+5)-2 \times (4+3+2+1)=32$. Therefore, the maximum value of $M$ is 32.
As shown in Figure 7, there are multiple valid ways to fill in the numbers.