You can't "roll back ordinals" because ordinals is simply a system for numbering individual satoshis.
I think OP actually wanted to say rollback Ordinal TX.
What can developers do to actually prevent that from happening in the future?
I mean really, I have no idea, that's why I ask.
What exactly do you mean by "prevent that"? If you refer to stopping people from storing arbitrary/non-transaction data on Bitcoin blockchain, it's impossible. Before Taproot exist, people can put arbitrary data using OP_RETURN, "fake" Bitcoin address and many other method. Although theoretically there are ways to make storing arbitrary data harder and more expensive.