A natural approach for this kind of problems when you don't know the result is to proceed as follows :
We may want to write the sum $\sum_{k=1}^n k^2$ as a telescopic sum, so we will try to find a polynomial of degree 3 ( why ? ) $P$ so that $P\left( k+1 \right) - P\left(k\right)=k^2$. Let $P\left( x \right) = ax^3+bx^2+cx$ for all reals $x$, then our constraint becomes :
$k^2= a\left( \left(k+1\right)^3 - k^3 \right) + b\left( \left(k+1\right)^2 - k^2 \right) + c$
Which after expanding and rearranging becomes :
$k^2 = 3ak^2 + \left( 3a+2b \right)k + a+b+c$
But we know that two polynomials are equal iff their coefficients are equal too, so we just need to solve this system :
$\left\{ \begin{aligned}
a &= \frac{1}{3} \\
3a+2b &= 0 \\
a+b+c &= 0
\end{aligned} \right.$
Which gives us $\left( a,b,c \right) = \left( \frac{1}{3}, \frac{-1}{2}, \frac{1}{6} \right)$
And Voilà, we just found the coefficients of our polynomial ! Now we just have to evaluate our telescopic sum :
$\sum_{k=1}^n k^2 = \sum_{k=1}^n P\left( k+1 \right) - P\left(k\right) = P\left(n+1\right)-\underbrace{P\left(1\right)}_{=0}$
$\sum_{k=1}^n k^2 = \frac{1}{3}\left(n+1\right)^3 - \frac{1}{2}\left(n+1\right)^2+\frac{1}{6}\left(n+1\right)$
$\sum_{k=1}^n k^2 = \frac{1}{6}\left(n+1\right)\left( 2 \left(n+1\right)^2 - 3 \left(n+1 \right) + 1 \right)$
$\sum_{k=1}^n k^2 = \frac{1}{6}\left(n+1\right)\left( 2n^2+n \right)$
$\sum_{k=1}^n k^2 = \frac{1}{6}n\left(n+1\right)\left(2n+1\right)$
Which completes the proof :-)