Lets look at the patterns:
There is $1$ square in a $1$x$1$ square.
There is $5$ squares in a $2$x$2$ square, 4 small, 1 large.
There is $14$ squares in a $3$x$3$ square, 9 small, 4 medium, 1 large
There is $30$ squares in a $4$x$4$ square, 16 small, 9 medium, 4 large, 1 extra large.
Notice anything? These are the square pyramidal numbers according to oeis and wikipedia says
'Square pyramidal numbers also solve the problem of counting the number of squares in an n × n grid.'
For an $n$x$n$ box, it is the sum of $n^2 + (n-1)^2 + (n-2)^2 + ... + 0^2$, or more simply the sum of $n^2$ and all previous squares
From this we can derive the final formula for the total amounts of squares, $t$ in an $n$x$n$ grid: