First, it is important to know that the United States presidential election is indirect. That means that it is not the people who chose the next President, rather than the United States Electoral College. This fact may surprise many readers, especially from Europe, where if 1 million people vote for a President, that candidate would receive 1 million votes. It is not like that in America. In the United States the total number of votes is set at 538 since 1964, because there are that many Electoral College members (electors).
Each of the states is allocated as many electors as the number of Representatives and Senators in the United States Congress that state has.
[...]
When the people vote, although they cast their vote for one of the presidential candidates, their vote is not counted towards the total vote count for President and Vice President, rather they are actually choosing Electors from their state. In turn, the Presidential Electors cast their vote, called "electoral vote", for the President and the Vice President.
[...]
Keep in mind that the Presidential Electors could vote for anyone they choose to, but with rare exceptions they vote for the designated candidates.
[...]
Basically, when you vote for President, you don't vote directly, but you "tell" the electors in your state who should they vote for.
[...]