The answer is all $n \equiv 0, 2, 3, 4 \pmod 6$ which clearly work since we can divide the ${}n \times n$ grid into $2 \times 2$ or $3 \times 3$ squares. It remains to show that the other two cases don't work:
If $n = 6k+1$, then label the rows $1, 2, \dots, n$ and put a $0$ all squares whose row is divisible by $3$, and put a $1$ otherwise. Then the numbers in each $2 \times 2$ square sum to $2$ or $4$, the numbers in each $3 \times 3$ sum to $6$, but the sum of the numbers in the grid is $(4k+1)n$ which is odd.
If $n = 6k+5$, then label the rows $0, 1, \dots, n-1$ and put a $0$ all squares whose row is divisible by $3$, and put a $1$ otherwise. Then, as before, the numbers in each $2 \times 2$ square sum to $2$ or $4$, the numbers in each $3 \times 3$ sum to $6$, but the sum of the numbers in the grid is $(4(k+1)-1)n$ which is odd.