Because the USA elects its president using an electoral college, not by having a simple vote.
The way it works, according to the constitution, is that the president is elected by 538 electors, chosen by the states. To decide who the electors should be, each state has an election and it's THAT election that voters vote in. And nearly all the states use "winner takes all" - whether a candidate wins by one vote or by thousands, all that state's electors will be chosen from that candidate's supporters. Let's take, for example, Florida - it chooses 29 electors, Trump only narrowly won there, but that still meant ALL 29 places went to Republicans and all the votes for Clinton in Florida didn't count.
Furthermore, the electors deliberately aren't spread between the states according to population. Each state has two however big or small it is, and only the rest go according to population. This is part of the compromise reached when the constitution was written. The small states wouldn't agree to it unless they got some say just for being a state - "surely that should count for something in a federal country?" So it was agreed to put in a little bit of bias towards smaller states. Live in a small one and your vote counts more.
Put those facts together and you see that what matters is not just the number of votes, but where they are. Trump got more votes in places where it counted more. So when the electors voted, Trump got 304 votes to Clinton's 227, with 7 votes going to other candidates, so he won.
In fact the states don't have to hold an election at all. The constitution is clear - the states choose electors and the electors vote. HOW the states choose electors is up to them. And until 1868, some states didn't hold an election. The state legislature chose the electors.
However, these days they all do hold an election, that happens in November, but it is still formally true that only the electors voting in December counts. We expect that all the electors will vote for who they're told to vote for, in some states it's illegal if they don't, so nobody much takes notice of the vote in December. But according to the constitution, it's only the vote in December that counts. And Trump clearly won that so he's president.