The reason for the split in 1876 and 1888 is likely that black voters were prevented from voting in most of the South (other than those 3 states in 1876). The percentage differences in the national popular vote were small enough that this could have made the difference, as the Republican Party was the choice for pretty much all black voters. Plus, Democrats barely lost important Northern states.
It's also worth noting that Lincoln would have been toast in a national PV runoff with Douglas, so the EC at least has that going for it. On the other hand, Wilson (yuge net negative for the country IMO) would have been toast in a national PV runoff with Teddy Roosevelt.
And the EV/PV split in Kennedy's favor is a real thing using the most mathematically correct way of allocating votes in Alabama. I don't know why historians have allowed that one to get memory holed.
? Kennedy won Alabama by nearly 100K votes.