The judge and the prosecutor have a common goal--to see that Trump is convicted (and probably sentenced to prison). If Michael Cohen's comments influence jurors and make that more likely, it's all fine and good. But Trump saying something might lessen the chances he will be found guilty so they can't allow that.
How often have defendants had a gag order placed on them?