> This is unconstitutional in Brazil per article 5 of the 1988 constitution, so X refused the orders.
This is unconstitutional according to their interpretation of the (very extensive and vague) article 5 of the 1998 constitution, maybe. At the same time, if you disagree with a judicial order, you probably should appeal the order, rather than refuse/ignore it. Ignoring judicial orders has consequences.
> Note that the text of the Brazilian constitution explicitly says that the freedom of expression is guaranteed without censorship (it mentions “censorship”).
It says a lot of things (that can be interpreted in many ways). Note that it also says "é livre a manifestação do pensamento, *sendo vedado o anonimato*". Did Twitter/X refuse to give information about accounts, after having been asked by the Supreme Court? If yes, then it can also be said that they are breaking article 5 of the 1988 constitution.
In general, constitutional laws (in Brazil and elsewhere) tend to be rather vague. The devil is in the details. Just because it says somewhere that "é livre a expressão da atividade intelectual, artística, científica e de comunicação, independentemente de censura ou licença", doesn't mean that you are free to express your art of screaming "fire" in a crowded theater, for instance.
> If they were legal orders they would have complied, as they have in other countries.
In general, a person (or other legal entity) are not free to pick and choose what laws or judicial orders they want to follow, depending on their own interpretation of the law. Or, I mean... they can... but there are usually consequences to ignoring judicial orders.
Also, it probably is not a great idea to try to intimidate/aggravate/insult/threaten the judge (https://nitter.poast.org/elonmusk/status/1829005086606901481...) during those legal proceedings. Judges tend to not love that.