My understanding is X followed Brazilian law by deleting the 7 offending posts, but the judge is now acting outside of the law and is demanding things of which there is no legal basis. And apparently this judge has a history of doing things like this in unrelated cases.
If you do business in a country without a strong tradition of the rule of law, you have to accept that the law is not the supreme authority. Sometimes the authorities do what they want, and you have to deal with it if you want to continue doing business.
As long as the order is upheld on appeal, you have to obey it. That's how courts work in the US too. It's the judge who decides. Judicial appointments matter.