But if electors are supposed to follow the popular vote and the
popular vote is for candidate A, then how does candidate B amass
enough elector votes to win in A's place?
Electors are bound to follow the popular vote in their state (but not always), not the US as a whole. On a national level, the electoral vote differs from the popular vote for two reasons:
(1) The winner-take-all system
In all but two small states (Maine and Nebraska, which allocate electors by Congressional district), a candidate need only win a bare plurality of the popular vote to win the state's entire slate of electors. Getting 50.001% of the vote (or even less, with third parties on the ballot) is just as good as 100%.
It happens that Trump won several important “swing states” with thin margins:
- Florida (29 EV), 49.1% to 47.8%
- Pennsylvania (20 EV), 48.8% to 47.6%
- Michigan (18 EV), 47.6% to 47.3% (preliminary — not yet “called” by most media outlets)
- North Carolina (15 EV), 50.5% to 46.7%
- Arizona (11 EV), 49.5% to 45.4%
- Wisconsin (10 EV), 47.9% to 46.9%
This translates to an Electoral College landslide even though the popular vote is close.
(2) Electoral College malapportionment
The number of electors a state has is equal to its number of seats in the House of Representatives (apportioned based on population) plus its number of Senators (always 2). These two “Senatoral“ votes skew the votes/population ratio in favor of small states.
(Note that since the ratio of Representatives to Senators is not fixed by the Constitution, this effect depends arbitrarily on the size of the House.)
California, the most populous state (37 341 989 according to the 2010 Census on which the current apportionment is based) has 55 electoral votes, or one electoral vote per 678 945 residents.
Wyoming, the least populous state (568 300) has the Constitutional minimum of 3 electors (for 1 Representative + 2 Senators), or one for every 189 433 residents.
In this sense, a Wyoming voter is “worth” 3.6 times as much as a California voter.
Trump appealed more to rural voters (and thus, small-population states), so benefited more from these “Senatorial” votes.