A knight's graph on an N-by-N board
MATL, 17 16 bytes

t&amp;l[2K0]B2:&amp;ZvZ+


Try it online!

(-1 byte thanks to @Luis Mendo.)

The main part of the code is creating a matrix \$ K \$ for convolution:

$$ \mathbf{K} = \begin{pmatrix}0&amp;1&amp;0&amp;1&amp;0\\1&amp;0&amp;0&amp;0&amp;1\\0&amp;0&amp;0&amp;0&amp;0\\1&amp;0&amp;0&amp;0&amp;1\\0&amp;1&amp;0&amp;1&amp;0\end{pmatrix} $$

(Relative to the centre of the matrix, each 1 is a valid knight's move.)

t&amp;l - Form a nxn matrix of all 1s (where n is the input). Let this be M.

[2K0] - Push an array containing [2, 4, 0] on stack

B  - Convert all to binary, padding with 0s as needed

0 1 0
1 0 0
0 0 0


2:&amp;Zv - Mirror that on both dimensions, without repeating the final row/column ("symmetric range indexing").
This gives us the required matrix K. 

0 1 0 1 0
1 0 0 0 1
0 0 0 0 0
1 0 0 0 1
0 1 0 1 0


Z+ - Perform 2D convolution of K over the earlier matrix M (conv2(M, K, 'same')),
summing up the 1s at legal knight move targets for each position  

Result matrix is displayed implicitly.