The Supreme Court is only involved because a state passed a law banning these treatments, and someone brought a case against the state saying the law is unconstitutional. Deciding which laws are unconstitutional is like the main purpose of the Supreme Court.
But I guess what you’re saying is why is the state passing these laws, which is a fair enough question. The Supreme Court says they are allowed to, and they are the authority on which laws are allowed, so I expect the states will keep doing this sort of thing until the voters tell them not to.
Plato did try to warn us that democracy was a terrible idea.
It should be up to a doctor to decide if a prescription makes sense for a particular patients symptoms and diagnosis. The Supreme Court should not concern itself otherwise.
At least with Roe v Wade there's an argument to be made about it involving a second hypothetical person. But this? This is strictly between patients, their medical care, and their parents.