Let
$$
S(n)=1^2+2^2+\cdots+n^2.
$$
Since $S(n)-S(n-1)=n^2$ one can suspect that $S(n)$ is a cubic polynomial in $n$. Obviously, $S(n)\in\Bbb Z$ for all $n=1$, $2$, $3\dots$ and one knows that the ring of numeric polynomals, i.e. the polynomials in $\Bbb Q[X]$ which take integer values on $\Bbb N$ is freely generated over $\Bbb Z$ by the binomial coefficients
$$
\binom Xk=\frac1{k!}X(X-1)\cdots(X-k+1).
$$
Thus one may attempt to write
$$
S(n)=a\binom X0+b\binom n1+c\binom n2+d\binom n3,
$$
for some $a,b,c,d\in\Bbb Z$ (since $\binom Xk$ has degree $k$, those with $k\geq4$ will not enter). Some fiddling allows to find the right coefficients and confirm the formula.