If we find the MGF of $$Z^2$$ where $$Z \sim N(0,1)$$ we find that $$M_{Z^2}(t) = (1-2t)^{-.5}$$ for $t < .5.$
Consider that a chi squared distributed variable $X$ with $r$ degrees of freedom is the sum of $r$ iid standard normal variables squared.
ie: $$X \sim \chi^2(r) = \sum_{j=0}^r Z_j^2$$ where $$Z_j \sim N(0,1)$$ are independent
therefore the mgf of chi squared is $$M_X(t) = (1-2t)^{-r/2}$$ Then $$M'_X(t) = -r/2\cdot-2r(1-2t)^{-r/2-1} = r(1-2t)^{-r/2-1}$$ so $$E(X) = r(1) =r$$
And then $$M''_X(t) = r\cdot-r/2\cdot-2r(1-2t)^{-r/2-2} = r^2 (1-2t)^{-r/2-2}$$ so $$E(X^2) = r^2$$ But this implies that $$Var(X) = E(X^2) - (E(X))^2 = r^2 - r^2 = 0$$ Which is obviously false as the variance of chi squared depends on $r.$
Where is the mistake in my derivation?
I fixed the proof based on BruceET's comment on the question. It is correct as follows.
If we find the MGF of $$Z^2$$ where $$Z \sim N(0,1)$$ we find that $$M_{Z^2}(t) = (1-2t)^{-.5}$$ for $t < .5.$
Consider that a chi squared distributed variable $X$ with $r$ degrees of freedom is the sum of $r$ iid standard normal variables squared.
ie: $$X \sim \chi^2(r) = \sum_{j=0}^r Z_j^2$$ where $$Z_j \sim N(0,1)$$ are independent
therefore the mgf of chi squared is $$M_X(t) = (1-2t)^{-r/2}$$ Then $$M'_X(t) = -r/2\cdot-2r(1-2t)^{-r/2-1} = r(1-2t)^{-r/2-1}$$ so $$E(X) = r(1) =r$$
And then $$M''_X(t) = r\cdot -(r/2 + 1) \cdot -2r(1-2t)^{-r/2-2} = (r^2 + 2r) (1-2t)^{-r/2-2}$$ so $$E(X^2) = r^2 +2r$$ And this implies that $$Var(X) = E(X^2) - (E(X))^2 = r^2 + 2r - r^2 = 2r$$ Which is the correct result.