Because Cameron's whole move was retarded from the beginning. He promised the referendum to shut up the eurosceptics in his own party if he ever would be able to govern alone, ie not in a coalition government. Then, unexpectedly, he won an outright majority in the last general election and suddenly could no longer hide behind the Liberal Democrats (his former coalition partner), who were against the idea. Accordingly, he went along and promised to hold the referendum, thinking that a majority would vote Remain. That would have let him get over the issue, shut up the eurosceptics in his own party, and would finally settle the question of Britain's intentions with respect to EU membership. Or so he hoped. Because it's quite easy to see that if the result would have gone the other way, ie Remain winning by a small margin, the anti-EU groups would have started to campaign for a second referendum in no time, using whatever excuses they could drag up to justify why the situation supposedly had changed so much that they would have to hold another referendum. The other option, that he might actually lose that referendum, apparently was unthinkable for him, even though he botched it as much as seems possible.
You could say it began with the Tories pulling out of the EPP (European People's Party, the European party of the conservatives/christian democrats) to form his on European party, the ECR (European Conservative and Reformists), because the former was too pro-European for his tastes. It's easy to see why instead of stealing the British eurocritics thunder, it legitimized their position, ie that there was something fundamentally wrong with the rest of Europe's mainstream politicians. Additionally, it had the effect of diminishing Britain's influence in the EU. Before EU summits, it's tradition for the EU leaders to have separate meetings to consult with other EU leaders of the same parties. Suddenly, Cameron was excluded from the EPP's consultations and as there are no other serious parties in the ECR besides the British Conservatives, had no one to talk to. The only other European leader sharing that fate is Greek PM Tsipras, as his SYRIZA party is the only member of the European Left which holds a prime ministership or presidency in an EU member state.
Then, when it came to actually starting the process of going about the referendum, he promised that he would go to Brussels, try to get a better deal, and that he would campaign against withdrawing from the EU, if he thought the deal was good enough. Unfortunately, most of what he said he would negotiate about was completely unrealistic, going against fundamental principles of the Union, and therefore out of hand unacceptable for the rest of the EU. What concessions he got were still more than generous and beyond anything any other EU country has, but in comparison to his grand promises they seemed like a joke. Accordingly, instead of convincing some eurosceptics that it was nevertheless better for Britain to stay in the EU, it had the opposite effect, as his stance basically said that the current deal for Britain with the EU was not good enough to justify EU membership.
But not enough, yet. When the campaigning for the referendum started, as the prime minister and in the absence of a functioning Labour Party, he became the leader and figurehead of the Remain campaign by default, which he utterly and unbelievably botched. Instead of trying to convince the British voters what benefits the UK got out of its EU membership, it was mostly based on fear of what would happen if it left the Union. Those predictions were not necessarily wrong, but without a concrete plan for how Britain would handle itself if the referendum went against his wishes, it made it hard for everyone with negative opinions of European integration to dismiss them as baseless fear-mongering and allowed the Leave campaign to promise milk and honey without having to put forward any concrete vision of what they wanted instead of an EU membership.
Ironically, had he actually put some thought into how Britain's future outside the EU could look like, drawn up a serious plan and put it forward as the alternative to the status quo, it's likely that he would never had worried about implementing it. Because in that case voters would have been able to seriously compare the drawbacks and benefits of EU membership with a credible alternative and make an informed decision on whether the alternative really was preferable. In the absence of such a plan, however, it was very inviting for everyone somewhat sceptical of this whole EU thing to project all their personal fantasies on what would happen if the UK would leave the Union, without having to face a realistic debate about what the actual consequences of such a decision would be.
TLDR: You probably have to go back quite a bit in British history to find a prime minister who did more damage to the United Kingdom due to sheer incompetence than Dave Caeron.