Because that’s how the judicial system works.
Somebody brings a case stating that there’s a problem with some law or policy. The judge may order that, until the trial is over, the policy be put on hold. Whether they do really depends on the judge’s call on whether continuing the policy or stopping it during the trial will cause more problems.
If the judge rules for the people making the complaint when the trial is over, the judge is empowered to tell the government, “hey, you wrote this policy, but it is not in keeping with other rules and policies that supersede it. I’m ordering it be stopped.”
If the state doesn’t like this result, they’re welcome to appeal to a higher court. Eventually, though, either the state or federal supreme court may hear the case and then there’s no one left to appeal to.
Latest Answers