The Ottomans did not defeat the British and French navies at Gallipoli although they did cause them losses with mines and the help of a German submarine.
The Allied navies were able to land, supply and eventually evacuate the military invasion force which while not routed, did not manage to advance far enough inland to be able to achieve their objectives and were eventually withdrawn. Withdrawing the Allied troops almost without loss in 1916 from trenches in easy range of Ottoman infantry and artillery was one of the few major things that went completely right.
Why did the land invasion not achieve anything?
The same factors that made for deadlocked trench warfare on the Western Front applied here too, such as the size of the armies in relation to the area they fought over, the defensive firepower of machine guns, cordite powered repeating rifles and artillery; the more primitive state of communications technology making it hard for commanders to be quickly aware of or able to move large bodies of troops to exploit fleeting opportunities opening up on the battlefield; and to an extent the less developed state of motorised and armoured transport to allow swift attacks.
However, motorised and armoured transport (e.g. tanks) even if available would have been hard to use in the mainly mountainous terrain, which was anyway more of a barrier than on most of the Western Front.
The recovery of Turkish morale when defending their own country and capital against foreign 'infidels'.
The emergence of a determined Turkish general Mustafa Kemal (later called Ataturk) "I don't order you to fight, I order you to die."
Certainly mistakes were made, but then mistakes usually are made. Things may have been somewhat worse than usual because the British Empire had, unusually among the main participants, begun the War without a large conscript army. Many of the troops and leaders sent to Gallipoli were necessarily still learning their jobs and the army was still learning how to function in a large scale industrialised war. The Gallipoli campaign was devised almost as an afterthought when some leaders like Kitchener realised it was hard to attack successfully against the Germans on the Western Front, but felt they had to attack somewhere, rather than leave Germany and her allies free to pummel Britain's isolated ally Russia undistracted.
Note: Some Australians and New Zealanders seem to want to believe that most fighting at Gallipoli on the Allied side was done by Australians and New Zealanders, who were all heroic and only failed because "the *&%$ing Pommie British were useless and *&%$ing Pommie British Generals were useless".
The Australian Peter Weir's 1981 film 'Gallipoli', starring Mel Gibson, seeks to confirm this prejudice by ending with Australian troops being sent to die in a doomed attack by a stupid British commander; in real life the episode portrayed did occur except the attack was actually ordered by an Australian Colonel.
By far the greatest number of Allied troops who gave their lives at Gallipoli were British, and that the French may have lost as many of their troops killed at Gallipoli as the Australians. Many people do not even know the French were there; some history books shamefully neglect their role.
The truth was that none of the Allied armies, French (including colonial Senegalese), British, Australian or New Zealand were able to break the deadlock to advance very far inland, but nor could any of them be dislodged by Ottoman counter-attacks.
PS In answer to requests below for sources, I mainly rely on the books 'Gallipoli' by Australian historian LA (or Les) Carlyon and 'Gallipoli' by British part-time historian (and former Member of Parliament) Robert Rhodes James. Also re the terrain having been there, in a tour group including Australians and New Zealanders who had no idea that many British or French troops had been in the campaign. The Turks now call the town we know as 'Gallipoli' (which the allies never actually reached) Gelibolu. See also probably any competent general biography in book or website of Winston Churchill, then First Lord of the Admiralty, whose political career was nearly ruined when he got the blame for the Gallipoli campaign, which he had advocated.