BUT a judge pulled some bullshit reason and declared it "unconstitutional", meaning it was voided, thats right in the United States of America a judge can declare something VIA THE CONSTITUTION to shut down something that WAS DEMOCRATICALLY DECIDED ON.
Okay, so if 51% of the public were communist and voted in a referendum to seize your property and then lynch you and your family and all of your neighbors, it'd be wrong for a judge to keep them from doing this?
Also, how do judges get appointed? By elected officials, right? Meaning judges are, in fact, indirectly elected officials. But their appointments are greatly staggered over time, meaning the judiciary as a whole doesn't reflect the mood of the public at one given moment, but rather the public's aggregated attitudes over time, which lean less radical. Furthermore, rules like the filibuster tend to discourage the appointment of judges who are too radical, since an appointee has to be acceptable to at least a few members of the other party.
It's no accident that the judiciary is the least partisan of our three branches. The public has its short term passions and prejudices, which they express at the ballot box. But their excesses are tempered by the moderates in robes. Overall our system is pretty balanced, which is why it's survived 236 years, a civil war, two world wars, many recessions and depressions, etc.