Let $T(n)$ denote the number of ways of coloring a $n \times n$ board with $x$ colors in such a way that each small square has a single color and the board looks exactly the same from all sides.
Let us now start from the squares which are close to the edges. There are $n$ squares on each side close to the edge. Consider any edge and start coloring from left to right. Each square has $x$ options till the $(n-1)^{th}$ square. However once we color the $n-1$ squares starting from left to right the colors on the other edges are automatically fixed. Hence, the number of ways of coloring the outermost set of squares is $x^{n-1}$. But once we do this, we now need to repeat this procedure for a $(n-2) \times (n-2)$ board.
Hence, $T(n)$ satisfies the recurrence, $T(n) = x^{n-1} T(n-2)$ where $T(1) = x$ and $T(2) = x$.
Hence, $T(2n) = x^{(2n-1) + (2n-3) + (2n-5) + \cdots + 1} = x^{n^2}$ and $T(2n+1) = x^{2n + (2n-2) + (2n-4) + \cdots + 4 + 2}x = x^{n^2 + n + 1}$