This feels like the equivalent of The Court defining pi as 3.2. There are many ways in which they could have ruled that the intent was to include tomatoes with vegetables, but to override science and give a ruling that a tomato has been a vegetable all along was the wrong way to handle the situation. Not the worst ruling ever, but definitely towards the wrong end of the scale.
This wasn't the government trying to redefine science, though; the court in its decision even acknowledged that botanically a tomato is actually a fruit. This case was only about the culinary definition for tariff purposes, just like how beans are considered vegetables instead of seeds.