Lemma. Let $G$ be a group and $H,K\subseteq G$ two subgroups such that one of them is normal. Then $HK=\langle H\cup K\rangle$.
Proof. So "$\subseteq$" clearly holds. Always.
WLOG assume that $K$ is normal, i.e. $gK=Kg$ for any $g\in G$. Let $x\in\langle H\cup K\rangle$. Then there are $a_1,\ldots, a_n\in H$ and $b_1,\ldots,b_n\in K$ such that
$$x=a_1b_1\cdots a_nb_n$$
By the $gK=Kg$ equality we can replace every $ab$ by $\tilde{b}a$ (and vice versa), and then by induction we can rewrite $x$ as:
$$x=a_1'\cdots a_n'b_1'\cdots b_n'$$
for some $a_1',\ldots,a_n'\in H$ and $b_1',\ldots,b_n'\in K$, meaning $x\in HK$. $\Box$
Now note that both $A=H$ and $B=K$, simply because $A$ is generated by all $a_i$, and adding $[a,b]=aba^{-1}b^{-1}$ doesn't do anything, since $ba^{-1}b^{-1}\in H$ because it is normal, and therefore $[a,b]\in H$. The same applies to $B$ and $K$.
Thus by our lemma we get that $AB=\langle A\cup B\rangle$, where the right side is clearly $M$.