Re: But he got less votes.
Because the US has a system of representative democracy. ('A' system, not 'the' system... there are many variations...)
We just had this discussion re the .eu domain, where the argument was whether UK MPs as representatives can ignore the expressed instruction of the people on a particular issue. (Based on comments and up- / down- votes, the majority view amongst commentators seemed to be that the representatives should be able to ignore the expressed will of the people, and decide for themselves).
While not especially familiar with the US election system, it appears that the people elected their representatives, who then chose President Trump.
If the US presidential election was run along the lines of a referendum-style '50%+1 for victory', then the US would now have President (H) Clinton (simplified - this assumes only two candidates, of course).
Of course, the same system that gave us (well, the US) President Trump also gave the US Presidents (W) Clinton, Obama, and Carter, amongst many others. (Examples selected because they are markedly 'not-Trump', not for any other reason).
Strangely, there seems to be a lack of appetite amongst US presidents of any/all political persuasion to try to significantly change the system that put them in power.