Question: How to derive this formula? 

$$n^2=\sum\_{k=1}^n(2k-1).$$

Answer: 
Well, since other had given formulae for calculating this sum, I will write a summing method from my primary school days: For $n=5$,

$$\begin{array}{c|c|c|c|c}
\times&\times&\times&\times&\times\\\hline
\color{red}\bigcirc&\color{red}\bigcirc&\color{red}\bigcirc&\color{red}\bigcirc&\times\\\hline
\times&\times&\times&\color{red}\bigcirc&\times\\\hline
\color{red}\bigcirc&\color{red}\bigcirc&\times&\color{red}\bigcirc&\times\\\hline
\times&\color{red}\bigcirc&\times&\color{red}\bigcirc&\times
\end{array}$$
You could use mathematical induction to do this:
First prove the statement for n=1 (or 0 if you like) and then prove that if it holds for n=k, it is also true for n=k+1. (You can do the last part by looking at differences between consecutive squares for example.)