MLE is negative while $\lambda$ should be positive
Solution 1:
From the distribution of gamma distribution,
$$f(x) = \frac1{\Gamma(k)\theta^k}x^{k-1}e^{-\frac{x}{\theta}}$$
Now, let $\theta$ be $\lambda$ and $k$ be $2$, we know that
$$f(x) = \frac1{\Gamma(2)\lambda^2}xe^{-\frac{x}\lambda}=\frac{xe^{-\frac{x}\lambda}}{\lambda^2}$$ is a valid distribution.
From your working, it shows that you are aware that power of $2$ should be there in the denominator.
Now, from $$-\frac{2n}{\lambda}+\frac1{\lambda^2}\sum_{i=1}^n x_i = 0$$
We have $$\frac1{\lambda^2}\sum_{i=1}^n x_i = \frac{2n}{\lambda}$$
Multiply by $\frac{\lambda^2}{2n}$,
$$\lambda = \frac1{2n}\sum_{i=1}^n x_i > 0$$
Note that the second derivative is
$$\frac{2n}{\lambda^2}-\frac2{\lambda^3}\sum_{i=1}^n x_i=\frac2{\lambda^2}\left(n-\frac{\sum_{i=1}^n x_i}{\lambda} \right)<0$$