Look up how use l'Hopital's rule. To use it on an indeterminate form $1^\infty$ as we have here, we need to take the logarithm, get an indeterminate form either $0/0$ or $\infty/\infty$, apply l'Hopital's rule to get the limit of that, then exponentiate.
\begin{align}
f(n) &= \left(1+\frac{2}{n}\right)^n,\qquad\text{indeterminate form }{1^\infty}
\\
\log f(n) &= n\log\left(1+\frac{2}{n}\right),\qquad\text{indeterminate form }\infty \times 0
\\
\log f(n) &= \frac{\log\left(1+2/n\right)}{1/n},\qquad\text{indeterminate form }\frac{0}{0}
\\
\log f(n) &\sim \frac{\frac{d}{dn}[\log\left(1+2/n\right)]}{\frac{d}{dn}[1/n]}\\
&\text{where I wrote $\sim$ for: "has the same limit as,}
\\
&\qquad\text{provided the limit on the right exists"}
\\
\log f(n) &\sim
\frac{-2/n^2}{(-1/n^2)(1+2/n)} = \frac{2}{1+2/n}
\\
\lim\log f(n) &= 2
\\
\log \lim f(n) &= 2
\\
\lim f(n) &= e^2 .
\end{align}
Question: Why is $1^\infty$ indeterminate?
Answer. Because we can get different results for limits of that form. Example
$$
\lim_{n\to\infty}\left(1+\frac{2}{n}\right)^n = e^2
\\
\lim_{n\to\infty} 1^n = 1
\\
\lim_{n\to\infty} \left(1+\frac{1}{n}\right)^{n^2} = +\infty
$$
and so on.