Judges will often bend over backwards to limit the possibility of a successful appeal. They don’t like having an appeals court overturn a verdict since it means they would then have to retry the entire case again.
By giving the defense multiple warnings they’re effectively preventing them from using this instance as a credible argument in an appeal. In an appeal the defense might say something like “the judge unfairly ruled against me regarding X”. But the appellate court will see in the transcript that the judge issued multiple warnings before ruling on X and use that to reject the claim.