Answer:
In 21 states, electors have the legal right to vote for whomever they choose. In the other states, the law requires electors to vote for their pledged candidate, but such laws have never been enforced. For instance, Republican elector Roger MacBride wasn’t prosecuted for giving his electoral vote to Libertarian John Hospers in 1972. If a large number of electors refused to vote as pledged, this might cause an uproar, but it wouldn’t be a constitutional crisis.
In principle, a presidential candidate could win 100% of the popular vote and still lose the election. There are least two ways that’s possible. First, faithless electors could reverse the popular vote. Second, many state legislators could directly appoint their own electors instead of allowing voters to choose electors. The U.S. constitution allows states to decide how electors are selected; there’s no requirement that you get any say this