Let $\Gamma$ be the Schur representation group of $G\cong A\times B$, and let $Z$ be the centre, so that $\Gamma/Z\cong G$. Let $Z_A$ denote the set of all elements of $Z$ of order coprime to $|B|$, and similarly for $Z_B$. Notice that $Z\cong Z_A\times Z_B$ since primes dividing $|Z|$ must divide either $|A|$ or $|B|$. I claim that $|Z_A|\leq M(A)$, and similarly for $B$, proving the claim.
Let $\bar\Gamma$ be the quotient $\Gamma/Z_A$. The preimage of $A$ (which is in $\Gamma/Z$) in $\bar\Gamma$ is a central extension of $A$ by $Z_B$, which has order prime to $A$. Thus this preimage is $Z_B\times A$, and so $A$ is (isomorphic to) a normal subgroup of $\bar\Gamma$. The preimage of $B$, on the other hand, is just some group $\tilde B$, yielding the decomposition of $\bar\Gamma$ given by
$$\bar\Gamma\cong A\times \tilde B,$$
where $\tilde B$ is an extension of $B$ by $Z_B$. We just need that $Z_B\leq \tilde B'$, but this is inherited from the fact that $Z\leq \Gamma'$.
This proves that $|Z_B|\leq M(B)$, and similar for $A$, and we are done.