This is just distribution of common factors in a sum . $(ab+ac)=a(b+c)$
You can "pull out" (distribute) factors in a series that do not contain the bound variable (or iterator) for that series (as a term or an index or such). The domain over which the bound variable is iterated is not a concern.
The bound variable of the inner series is $i$, and $2k$ does not contain $i$.
The distribution of the inner series is thus : $(2k+2k+\ldots+2k)=2k(1+1+\ldots+1)$.$$\sum_{i=1}^k 2k=2k\sum_{i=1}^k1$$
And hence $$\qquad\qquad\begin{align}\sum_{k=1}^n\sum_{i=1}^k 2k&=2\sum_{k=1}^n k^2\\[1ex]&\phantom{=\dfrac 26\cdot n(n+1)(2n+1)}\end{align}$$