A lot of Democrats and Independents voted for him in the early open primaries which carry disproportionate weight in determining the GOP nominee.
Way to fix the problem? Hold every State's primary on the same day, and close them so only Republicans can vote in them.
The other problem is that a candidate can win winner-take-all states with a mere plurality. McCain could take all the delegates in a state even though 65% of the voters voted for someone else.
State parties really need to think of going to a majority vote system.