$\newcommand{\doop}{\operatorname{do}}$It's a bit more complicated than that. As outlined in Causal Inference in Statistics: A Primer, by Pearl, Glymour, and Jewell, on p. 68, we follow this line of reasoning (variable $Z$ in the book changed to your $M$ for consistency):
First, we note that the effect of $X$ on $M$ is identifiable, since there is no backdoor path from $X$ to $M.$ Thus, we can immediately write $$P(M=m|\doop(X=x))=P(M=m|X=x).\qquad\qquad (3.12)$$ Next we note that the effect of $M$ on $Y$ is also identifiable, since the backdoor path from $M$ to $Y,$ namely $M\leftarrow X\leftarrow U\rightarrow Y,$ can be blocked by conditioning on $X.$ Thus, we can write $$P(Y=y|\doop(M=m))=\sum_x P(Y=y|M=m,X=x)\,P(X=x). \qquad(3.13)$$ Both (3.12) and (3.13) are obtained through the [backdoor, ACK] adjustment formula, the first by conditioning on the null set, and the second by adjusting for $X.$
We are now going to chain together the two partial effects to obtain the overall effect of $X$ on $Y.$ The reasoning goes as follows: If nature chooses to assign $M$ the value $m,$ then the probability of $Y$ would be $P(Y=y|\doop(M=m)).$ But the probability that nature would choose to do that, given that we choose to set $X$ at $x,$ is $P(M=m|\doop(X=x)).$ Therefore, summing over all states $m$ of $M,$ we have $$P(Y=y|\doop(X=x))=\sum_mP(Y=y|\doop(M=m))\,P(M=m|\doop(X=x))\quad (3.14)$$ The terms on the right-hand side of (3.14) were evaluated in (3.12) and (3.13), and we can substitute them to obtain a $\doop$-free expression for $P(Y=y|\doop(X=x)).$ We also distinguish between the $x$ that appears in (3.12) and the one that appears in (3.13), the latter of which is merely an index of summation and might as well be denoted $x'.$ The final expression we have is \begin{align*}&P(Y=y|\doop(X=x))=\\&\sum_m\sum_{x'}P(Y=y|M=m,X=x')\,P(X=x')\,P(M=m|X=x)\qquad (3.15)\end{align*} Equation (3.15) is known as the front-door formula.
The authors use the law of total probability in writing (3.13) and again in (3.14).
Carlos Cinelli has a very good answer here that contains more information.