Your composition formula is right ONLY if we assume no M--Y confounding.
But in general, even if M is the only mediator between X and Y, the formula does not hold. This is in fact a beautiful example how modern #causalinference deconstructs strongly held intuitions #Bookofwhy
Intuition says: We have two RCT studies, one gives P(Y|do(M)), the second gives P(M|do(X)), So, if we have a new study with X--->M--->Y the ONLY directed path from X to Y, we should forget confounding and chain the two causal effects together to get P(Y|do(X)). WRONG! We do
need to worry about confounding, but only Y--M, not X--M. It is also beautiful because it is not easy to show that the intuition is wrong, so I bet most traditional researchers would go wrong here. Funny, some researchers still refuse to believe in the revolution #Bookofwhy