Solution 1:

The problem is that the power rule

$$ (a^b)^c = a^{bc}$$

only holds when $a$ and $b$ are positive real numbers. In that derivation the crucially wrong step is

$$ (e^{2 \pi i n + 1})^{2 \pi i n + 1} = e^{(2\pi i n + 1)(2 \pi i n+1)}.$$

Solution 2:

In complex numbers, $e^a=e^b$ does not imply that $a=b$. For instance, $e^{2\pi in+1}=e$ does not imply that $2\pi in+1=1$.

For the same reason, $\log e^a$ is not the same as $a$, and $(e^a)^a:=e^{(\log e^a)a}$ is not the same as $e^{a^2}$ (instead it is $e^{(a+2\pi ik)a}$, for some $k$).