Why is $\pi^0 \rightarrow \gamma \rightarrow e^-e^+$ forbidden but $\pi^+\rightarrow W^+ \rightarrow e^+ \nu_e$ allowed?

The QCD and QED themselves conserve parity. The conclusion of this statement is that all corresponding effective vertices must conserve the parity. The only coupling of $\pi^{0}$ to $\gamma$ conserving the parity is $$ L_{\pi^{0}} \simeq \frac{\pi^{0}}{\Lambda}\epsilon^{\mu\nu\alpha\beta}F_{\mu\nu}F_{\alpha\beta}, $$ which doesn't allow your decay process $\pi^{0} \to \gamma^{*} \to e^{-}e^{+}$. To understand this, note that the pion fields are pseudo-scalars, while the photon field is the vector field, while the Levi-Civita tensor $\epsilon^{\mu\nu\alpha\beta}$ is the pseudo-tensor.

However, it is possible to construct the effective vertex allowing the decay $\pi^{0}\to e^{+}e^{-}$ through $Z$-boson, i.e., through weak interactions. The reason is that they directly violate the parity. Therefore, it is possible to construct phenomenological parity-violating low-dimensional effective interaction vertex $$ L_{\pi^{0}}' \simeq \Lambda'\partial^{\mu}\pi^{0}Z_{\mu}, $$ allowing the decay process $\pi^{0} \to Z^{*} \to e^{+}e^{-}$.

By the same reason, it is easy to construct parity violating vertex $$ L_{\pi^{+}} = \tilde{\Lambda}\partial^{\mu}\pi^{+}W^{-}_{\mu} + \text{ h.c.}, $$ allowing your decay process $\pi^{+}\to W^{+*} \to l^{+}\nu_{l}$.