Fortunately, their vote was in a referendum, which is not legally binding. It's still up to Parliament whether or not they proceed forward. Perhaps the PM's announcement of his resignation was premature in this regard, but it would appear the people will need to elect a new Parliament who then would vote to invoke rule 50 or whatever it is, that allows Britain to leave the EU.
I don't think Cameron's position was in any way tenable. He decided to run with that promise, and considering how everyone was surprised that the tories got a majority, I think it's reasonable to assume that it tipped the election enough to give the tories a commanding majority.
There wasn't any need for him to make such a promise; the general opinion is that he did it because it was a potential vote-winner and he didn't expect he'd need to honour it because he thought the next government would be another coalition like its predecessor.
Even though he made a promise, he could have broken it. It wouldn't have been the first time, and if the tories didn't make any howling errors during their next term, it wouldn't have been enough to lose the election after. So, he kept to an idiotic promise. Furthermore, he didn't put in place any bar (besides >50%) for the leave vote to count, despite the fact that if 50.01% of voters say x, that's not any kind of useful majority, that simply tells you that the country is divided right down the middle and an immediate second snap-referendum without any prep might yield the opposite result by the same margin.
He also claimed that he would endorse the leave campaign if he couldn't get us a good deal in Brussels. Nothing noteworthy changed by any account of that deal, yet he then supported remain. It made no sense.
Then he completely arsed up the remain campaign. Week in, week out he kept coming out with these vague, dark warnings like "we'll be less safe"; absolutely nothing of substance. Basically the same old shit his government has been putting out pre referendum as to why they need to spy the living daylights out of us, or their fear-mongering about immigrants (I wonder if this point was a major nail in remain's coffin, the fact that the government could act so hypocritically). He even started comparing the campaign to WW2! I think it pissed people off as well as doing the remain campaign no favours.
What the remain campaign needed was a logical argument that didn't rely on constant fear-mongering. For once, the British government might point out that the UK is actually in a fairly reasonable state considering the recent recession, for example. There are plenty of things to be upbeat about, then just point out that the brexit campaign is not offering a plan or any specifics about the risks, potential complications or even what the specific rewards are and how those might affect the average citizen; that would be a bare minimum for a responsible leader to consider risking the livelihoods of millions who may not have completely recovered yet from the previous recession; just a lot of bluster and "Rule Britannia!", just like a lot of moronic brexit voters online. Like a Positive Mental Attitude alone is going to get us through this mess. I'm reminded of the stoner/surfer in 'Platoon': "You've got to think positive dude! Count backwards or something!".
IMHO the UK's biggest problem (and possibly for many other nations too) is that we don't have leaders, we have career politicians. Politicians learn the craft of manipulation and back scratching as they each try to scramble to the top in their hunger for power. They don't bring change unless it directly benefits them: They offer the illusion of change to us for everything else. They use the technique perfected by the Nazis of "your problems are caused by x" to avert the peoples' attention from the real problems to a convenient scapegoat: Preferably an on-going threat that is not possible to neutralise in any remotely civilised manner.