As in the comment, @abhishek29 has mentioned a nice recurrence for the given problem. I am trying to explain how we can make this recurrence. If we get the recurrence, then we can get the answer easily because solving this recurrence is not difficult.
Finding newly added squares of sizes $1 \times 1, 2\times 2,...$ for each $T_i$ is not difficult at all. We just have to observe how many new squares of different sizes are creating each time when we add a new horizontal and vertical layer. Based on $T_3,T_4,T_5…,$ we can write:
$T_n = T_{n-1} + (n+ (n-1)) + ((n-1) + (n-2)) + ((n-2) + (n-3)) +….+1,$ for $n \geq 3$
($T_2$ is my base case here)
$T_n = T_{n-1} + n + 2((n-1) + (n-2) + ...+1)$
$T_n = T_{n-1} + n + 2 \frac{(n-1)n}{2}$
$T_n = T_{n-1} + n^2$