Here's a completely different proof. As you said, such a group is always abelian. Then $G$ becomes a vector space over the field with two elements $\mathbb{F}_2 = \{0,1\}$, by setting $0 \cdot x = e$ and $1 \cdot x = x$ (verify that this defines a vector space, in particular $e = 0 \cdot x = (1+1) \cdot x = x^2$ is satisfied).
Since $G$ is finite, it is obviously finitely generated (as a vector space over $\mathbb{F}_2$), and it's a standard fact of linear algebra that a finitely generated vector space has a basis. Let $\{g_1, \dots, g_n\}$ be such a basis for $G$. Then the map $\{0,1\}^n \to G$, $(\lambda_1, \dots, \lambda_n) \mapsto \sum \lambda_i g_i$ is a bijection (by the definition of a basis), and thus $G$ has the same cardinality as $\{0,1\}^n$, that is $|G| = 2^n$.