If we want to fill the empty squares by the numbers $1$, $2$, $3$, $4$, $5$, $6$ so that all the numbers appear in each row and column, how can we find the number of ways to do that?
$$\begin{array}{|c|c|c|c|c|c|} \hline \;1\strut\;& \;2\; & \;3\; & \;4\; & \;5\; &\;6\;\\\hline 2 \strut& & & & & 5\\\hline 3 \strut& & & & & 4\\\hline 4 \strut& & & & & 3\\\hline 5 \strut& & & & & 2\\\hline 6\strut & 5& 4& 3& 2& 1\\\hline \end{array}$$
The second row must contain a $3$ and a $4$, neither of which can be in either the third or the fourth column; thus, they must be in the second and fifth columns, in either order, and the missing $1$ and $6$ can then be filled in in either of two ways. That is, there are $2^2=4$ ways to fill in the second row acceptably.
Now proceed to the third row. It must contain a $2$ and a $5$, and they must go in the middle two columns; they can still go there in either order. The missing $1$ and $6$ will then fill the second and fifth columns, and they can appear in either order, so there are $4\cdot2^2=16$ ways to fill the second and third rows acceptably.
In the fourth row the missing $2$ and $5$ must occupy the middle two columns, just as in the third row. Thus, there is only one possible way to place them. The $1$ and $6$ must occupy the second and fifth columns, again just as in the third row, so they must be placed in the order not used in the third row. Thus, the layout of the fourth row is completely determined by the layout of the third row.
Similarly, the layout of the fifth row is completely determined by the layout of the second row, and the total number of acceptable arrangements is just $16$.
The array below shows the possibilities. Numbers separated by a slash are alternatives for that cell. The four red cells are free choices, but once they’ve been chosen everything else is completely determined.
$$\begin{array}{|c|c|c|c|c|c|} \hline 1&2&3&4&5&6\\ \hline 2&\color{red}{3/4}&\color{red}{1/6}&6/1&4/3&5\\ \hline 3&\color{red}{1/6}&\color{red}{2/5}&5/2&6/1&4\\ \hline 4&6/1&5/2&2/5&1/6&3\\ \hline 5&4/3&6/1&1/6&3/4&2\\ \hline 6&5&4&3&2&1\\ \hline \end{array}$$