In a randomized trial, the treatment is randomized, so there is no confounding of the treatment-outcome relationship or the treatment-mediator relationship. For those relationships, associations represent causal effects.
However, the mediator is not randomized. It is in part affected by the treatment, and in part effected by a collection of many other factors. If any of those factors also affect the outcome, you have confounding of the mediator-outcome relationship (sometimes called the "b" path). You need to adjust for this confounding in order to validly estimate the causal effect of the mediator on the outcome.
The confounding of the mediator-outcome relationship is the primary reason people are often skeptical of mediation analysis. For many mediators, it is impossible to observe enough variables to eliminate mediator-outcome confounding (i.e., to collect all common causes of the mediator and outcome other than the treatment).
In a randomized trial, you can estimate the causal effect of the treatment on the outcome (the total effect) and the causal effect of the treatment on the mediator (the "a" path), but you cannot estimate the causal effect of the mediator on the outcome (the "b" path) without additional work to remove confounding. A consequence of this is that you cannot estimate either the indirect effect or the direct effect; only the total effect is available without further adjustment.
Even if you do collect confounders of the mediator-outcome relationship, it is not straightforward to adjust for them if they are also caused by the treatment, which is yet anther difficulty with mediation analysis. Given these difficulties, mediation analysis should be used very sparingly and only in cases where we understand the confounding mechanism well and can adjust for it.
Note that none of is is "by chance"; everything I said above would be true even if we were able to run a randomized trial in the entire population (i.e., or an infinite sample size).