It’s not illegal for them to treat them as spam proactively. In fact, manufacturers and carriers and text messaging platforms are completely free to make the decision to block them (and some do).
It isn’t a first amendment issue either actually - it’s just that legislators lobbied for an explicit exemption in the laws passed around this (after all they wrote the text). CAN SPAM is an example.