Proving $\sum^n_{k=0} k^2 {n\choose k} = (n+n^2)2^{n-2}$ We can start with the expression of the binomial expansion, $\sum^n_{k=0} {n\choose k} x^ky^{n-k}= (x+y)^n$. Setting $x=y=1$ gives $\sum^n_{k=0} {n\choose k} = 2^n$
Differentiating both sides with respect to $x$ gives $\sum^n_{k=0} k{n\choose k} x^{k-1}y^{n-k} = n(x+y)^{n-1}$, and substituting $x=y=1$ gives $\sum^n_{k=0} k{n\choose k} = n2^{n-1}$
Differentiating again gives $\sum^n_{k=0} k^2{n\choose k} x^{k-2}y^{n-k} = (n^2-n)(x+y)^{n-2}$, and substituting $x=y=1$ gives $$\sum^n_{k=0} k^2{n\choose k} = (n^2-n)2^{n-2}$$
However, the identity is $$\sum^n_{k=0} k^2{n\choose k} = (n^2+n)2^{n-2}$$
I don't seem to have lost a sign somewhere, where is my mistake?

You have written  the second derivative of $x^{k}$ as $k^{2}x^{k-2}$. It is $k(k-1)x^{k-2}$.
If you add $n2^{n-1}$ to $(n^{2}-n)2^{n-2}$ you get $(n^{2}+n)2^{n-2}$.
