Let $X_1,X_2,\dots ,X_n$ be a random sample from the Gamma distribution
$$ f(x,\theta)=\theta^2 x e^{-\theta x},\quad x>0$$
To find the Maximum Likelihood Estimator, we define the likelihood function as: $$ L(\theta;x_i)=\prod_{i=1}^nf(x_i;\theta)$$ and we demand $$\frac{\partial \ln[L(\theta;x_i)]}{\partial\theta}=0$$ For this example $$L(\theta;x_i)=\theta^{2n}\cdot \prod_{i=1}^n x_i\cdot e^{-\theta \sum_{i=1}^nx_i}$$ $$\ln[L(\theta;x_i)]=2n\ln(\theta)+n\ln\bigg[\prod_{i=1}^nx_i\bigg]-\theta \sum_{i=1}^nx_i$$ So $$\frac{2n}{\theta}-\sum_{i=1}^n x_i=0\iff \hat{\theta}=\frac{2}{\bar{X}}$$ To find the estimator of $\theta$ using the method of moments $$\bar{X}=E(X)=\mu$$ $$E(X)=\int_0^\infty x f(x)dx=\theta^2\cdot\frac{2}{\theta^3}=\frac{2}{\theta}$$ $$\Rightarrow \tilde{\theta}=\frac{2}{\bar{X}}$$
Is there some kind of relation between the two? Why are the expressions of $\hat{\theta}$ and $\tilde{\theta}$ so similar?