The presidential elections in the US are realized through the electoral system - meaning that the people don't directly vote for the president, but for the Electors and the Electors vote for the president. Therefore, in order to win the elections, enough Electors in favour of one president must be chosen but some states have more electors per the same number of people so the votes of these people count more - and this is what happened.