He won, lost, and won the Electoral College and thus the presidency, even though he won the popular vote every time. Grover Cleveland learned that the Electoral College makes American politics truly national.
The genius of the United States of America: we are both United and States. The American system of states is Federalism. One part of it is the Electoral College, the state-by-state way we elect the President of the United States.