Assume a democracy where every person can vote. Now, if there was a party to say: "If we win, next time only all men are allowed to vote plus all women with dark hair." Let's assume that there are 50% men. Secondly we assume 25% women with dark hair. So for 75% of the population it would be a good idea to vote for this party as this grants them more power. After they have won, they declare: "If we are elected again, only men will be allowed to vote next time." So men would make up the majority of the now-allowed-to-vote people, such that little by little we could boil down power to a small group of people. Why doesn't this happen? The same question in a different context: How did gay people get the right to marry, although a lot of people oppose this? In my (pro-gay) opinion we often get laws that are way more humane than the people living under them are. What force drives us away from the lynch-mob? I hear a lot about democracy representing the opinions of the majority, but I feel the way more important job of a democracy is to protect minorities, rather than doing "what most people want". Why arent we stuck in a lynch-mob society?
Edit: Thanks for the answers and comments. What I took so far is that courts and some sort of fundamental rights have to be in place to avoid the problem. Furthermore there is not a final answer to deal with the problem once and for all. It is always subject to societies and the people. This is good to know for me, as I was not sure if there was a optimum solution to the problem. However, I am new to this and the problem has emerged in my head steming from a very different context, such that I appologize not being able to have done my own research as I just don't know what to even search for. Does this problem have a name, is there research about it, is there something I can google for? I started here as I had no clue on how to even get started.