The United States is not, nor has it ever been, a democracy; it is a republic. You are electing the electors who then cast their vote for the president. When the elector votes contrary to the popular vote, it's the same idea as a president who doesn't do what he promises during his campaign.