We know that $e^{\pi i} = -1$ because of de Moivre's formula. ($e^{\pi i} = \cos \pi + i\sin \pi = -1).$
Suppose we square both sides and get $e^{2\pi i} = 1$(which you also get from de Moivre's formula), then shouldn't $2\pi i=0$? What am I missing here?
You have shown that $e^{2\pi i} = e^0$. This does not imply $2\pi i = 0$, because $e^z$ is not injective. You have to give up your intuition about real functions when you move them to the complex plane, because they change a lot. $e^z$ is actually periodic for complex $z$.