>Democracy does not mean the majority gets whatever it wants.
Yes, it does. By definition democracy is doing whatever the majority wants to do.
>protecting the rights of the minority
Under democracy the minority opinion can be ignored. Rights only need to be protected if the majority wants. And the majority can decide what is and isn't considered a right.
If minority rights are not maintained, then the first majority to win will change the rules/system so that the minority can never become the majority. In the extreme example, the 51% votes to eliminate the 49%. For a democracy to function minority rights and checks on the majority power are fundamental requirements.
>so that the minority can never become the majority
So you are trying to say that a democracy that is unable to find a global maxima is not a functional democracy? I would disagree and say that a democracy moving towards a local maxima is still functional.
That is still not how democracy works! Non-commissioned officers don't swear an oath to upholding the constitution or the people's vote, only to the Commander in Chief. The majority of Americans (and even Congress) could vote in favor of a military invasion of Mexico, and it would be fully constitutional for the sitting president to ignore their vote.
"The majority" changes the Commander in Chief, who in turn can be held liable for violating constitutional democracy if they abuse discretionary powers (see: Richard "I am not a crook" Nixon).
Not every decision by the US government is made democratically. Sometimes a delegate is voted upon. In this case last year a new commander and chief of the US military was voted in who has this power.