I ended up being inadvertently reminded of this topic while reading about early Ottoman history and the surrender of Gallipoli by the Byzantines. I've had a look at the previous answers to questions and they all seem to discuss the operational and strategical failures from the British side. But the Ottomans fended off invading troops who possessed an enormous numerical advantage, causing massive casualties, albeit at great costs to their own ranks, and this can hardly be understood entirely in terms of incompetence on behalf of the invaders.
The first two days was the critical period - after the Allies had failed to take their first-day objective after two days, the Ottomans held the commanding terrain (i.e., the Allied first-day objectives), and were growing stronger. What the Ottomans did right was tenacious defence at the low level, and energetic and insightful leadership at the higher levels, battalion commanders and up.
There were dangerous gaps in some places where the British landed, but quick reaction by the Ottomans and lack of any real attempt to exploit the gaps by the British before they could be plugged. Notably, the Ottoman defence of Y beach had been built up from the original 9 men to one and a half battalions by nightfall, and they attacked with sufficient determination during the night and morning so as to cause the British to withdraw (despite still outnumbering the Ottomans).
The defences at Anzac Cove were light, and only a quick Ottoman response kept Chunuk Bair, the high ground which was the key to defending the area throughout the campaign, in Ottoman hands. Mustafa Kemal, commander of the 19th Division, was ordered to send a battalion. Instead, realising the importance of Chunuk Bair, he took a regiment, and on arrival, counter-attacked on his own initiative. This, combined with the determination of his troops, saved Chunuk Bair.
The performance of the Ottoman troops is exemplified by some of their actions on the first day:
Mustafa Kemal met Ottoman troops retreating from the ANZACs after having run out of ammunition. He ordered them to fix bayonets, and stay. They did.
The regiment Mustafa Kemal took to Chunuk Bair, the 57th, lost half its men in its defence of Chunuk Bair and counter-attacks to push the ANZACs back. Similarly, the Ottoman forces counter-attacking at Y beach lost half their men.
Without this determination to fight, the initiative and quick response of the Ottoman commanders would have been insufficient. Without that active response by their commanders, all that Ottoman determination at the low level would have achieved would have been death in return for insufficiently delaying the Allies. Together, they managed to hold the high ground dominating the battlefield, ensuring the eventual Ottoman victory.
For a longer discussion and references, see: