The charges against her are not about her behavior during her court, they're about what happened once the court was adjourned and the defendant was starting to leave. She successfully defended the process within her own courtroom and it's alleged that she went a step further in securing the defendant from their impending arrest on an unrelated charge.
There's definitely a conversation to be had about whether people should be safe from immigration law enforcement while within a courthouse, but at the moment as I understand it that is not a protection that exists.