Okay, so the reason why there where 2 [or 3] cases in which the
popular vote didn't lead to the white house are based on the fact
that some unpledged electors messed up by voting against their
states popular vote outcome, right?
No, the reason is it's calculated on state level, as explained by others before. Let's try one more example. Suppose the US consisted of only two states, California with 36 mn inhabitants and Pennsylvania with 12 mn inhabitants. Based on an average of 600,000 inhabitants per House Rep., they'd get 60 resp. 20 House Reps.
(the numbers are slightly off, but this is generally how it goes; for the sake of simplicity, I'll also assume all inhabitants to be voters)
Now the number of Electors is equal to the number of House Reps. plus the number of Senators - the latter is always 2. So California gets 62 electors and Pennsylvania 22.
Now assume 19 mn Californians vote Democrat, and 17 mn vote GOP. Assume also that 4 mn Pennsylvanians vote Democrat and 8 mn vote GOP (McCain would like to

). Then the Dems have 62 electors from California and the GOP only 22 from Pennsylvania. But the GOP won the public vote overall.
Now factor in that there are 50 states, ranging in population size from barely 600,000 - such as Vermont and Alaska - which thus get 3 electors, to California with 55 electors, and you see that you can get all kind of skewed results.
BTW, do you understand how the German Bundestag elections work? The way the US president is elected is child's play compared to that...