The first step in calculating the variance of a Binomial Random Variable is calculating the second moment.
I have no idea as to how the last two steps have happened. Why is a n(n-1)p^2 outside the first summation and a similar expression outside the second? Also, how did the expression turn out to be the last equation?

First term is obtained as follows:
\begin{align} \sum_{j=0}^{n} \frac{n!(j^2-j)}{(n-j)!j!}p^j(1-p)^{n-j} &= \sum_{j=2}^{n} \frac{n!(j^2-j)}{(n-j)!j!}p^j(1-p)^{n-j}\tag{1}\\&=\sum_{j=2}^{n} \frac{n!(j(j-1))}{(n-j)!j!}p^j(1-p)^{n-j} \tag{2}\\ &= \sum_{j=2}^{n} \frac{n!}{(n-j)!(j-2)!}p^j(1-p)^{n-j} \tag{3} \\ &= n(n-1)\sum_{j=2}^{n} \frac{(n-2)!}{(n-j)!(j-2)!}p^j(1-p)^{n-j} \tag{4}\\ &= n(n-1)p^2\sum_{j=2}^{n} \frac{(n-2)!}{(n-j)!(j-2)!}p^{j-2}(1-p)^{n-j} \tag{5} \\ &= n(n-1)p^2\sum_{j'=0}^{n-2} \frac{(n-2)!}{(n-2-j')!(j')!}p^{j'}(1-p)^{n-2-j'} \tag{6} \\ &= n(n-1)p^2 \tag{7} \\ \end{align}
where equation $(1)$ is due to $j^2-j=0$ if $j=0$ or $j=1$, hence we can start summing from $2$ rather than $0$.
Equation $(2)$ is just $j^2-j=j(j-1)$.
Equation $(3)$ is due to $j!=(j-2)!j(j-1)$
Equation $(4)$ is due to $n!=(n-2)!n(n-1)$.
Equation $(5)$ is just factorize $p^2$ outside.
Equation $(6)$ is a change of variable of $j'=j-2$
To obtain equation $(7)$, notice that in equation $(6)$, the term inside the sum if the pmf of binomial distribution with parameter $n-2$ and $p$.
I will leave the second term as an exercise.