States get to choose how they cast their votes. They don't even need to have an election, they can just appoint electors. They could also choose for vote for the person that wins the popular vote.
THE FINAL VOTE COUNT:
CLINTON: 65,844,610 (48.2%)
TRUMP: 62,979,636 (46.1%)
OTHERS: 7,804,213 (5.7%); CLINTON HAD THE THIRD MOST VOTES OF ANY PRESIDENTIAL CANDIDATE IN HISTORY