Why these $2$ methods give the exact same answer for sum of squares?

Visual proof of $$\sum_{k=1}^{n}k^2=\sum_{k=1}^{n} (2k-1)(n+1-k).$$ Take a look at this picture for $n=5$.

enter image description here $$1+2^2+3^2+4^2+5^2=\underbrace{1\cdot 5}_{k=1}+\underbrace{3\cdot 4}_{k=2} +\underbrace{5\cdot 3}_{k=3}+ \underbrace{7\cdot 2}_{k=4}+ \underbrace{9\cdot 1}_{k=5}.$$


The first sum is $\sum _{n=1} ^k n^2 $ , while the second sum is $\sum _{n=1} ^k (2n-1)(k+1-n)$ .

Let us try to relate the two. We have :-

$$\sum _{n=1} ^k(2n-1)(k+1-n) =k\sum _{n=1} ^k(2n-1) -2\cdot\sum_{n=1} ^kn^2+\sum_{n=1}^kn+\sum_{n=1}^k2n-1$$ $$=2k\cdot\frac{k\cdot(k+1)}{2} - k^2 -2\sum_{n=1}^kn^2+\frac{k\cdot(k+1)}{2} +2\cdot\frac{k(k+1)}{2}-k= \frac{k\cdot(k+1)\cdot(2k+1)}{2}-2\sum _{n=0}^kn^2= 3\cdot \sum _{n=0}^kn^2-2\sum _{n=0}^kn^2=\boxed {\sum _ {n=1} ^k n^2} $$


Alternatively: $$\sum_{k=1}^n k^2=1^2+2^2+3^2+\cdots +n^2=\\ \color{red}1+(\color{red}1+\color{blue}3)+(\color{red}1+\color{blue}3+\color{green}5)+\cdots +(\color{red}1+\color{blue}3+\color{green}5+\cdots +\color{brown}{(2n-1)})=\\ \color{red}1\cdot n+\color{blue}3\cdot (n-1)+\color{green}5\cdot (n-2)+\cdots +\color{brown}{(2n-1)}\cdot 1.$$

Note: This is an algebraic presentation of Robert Z's wonderful PWW!