That is what happened here. Petioning courts to overturn unconstitutional actions by the other branches of government is an integral part of the American system.
The law requiring the children to recite the Pledge or sing the National Anthem was written by people who were elected by a majority vote to serve the needs of the state of Pennsylvania. The judicial panel that overturned the law was not elected by a majority of the voters and is not specifically charged with representing their interests.
Our system is set up in such a manner that the majority cannot do certain things, no matter how much it wants to. Our Founding Fathers were very careful to set up a system where the majority cannot take away the rights of the minority.
"-Our Founding Fathers were very careful to set up a system where the majority cannot take away the rights of the minority.-"
The minority (3 people) have taken away the rights of the majority (elected representatives of the people).