I've just read up a bit on the Gallipolli campaign, and apparently a part of the reason the Ottomans were dragged into a war against the allies was that Rear Admiral Wilhelm Souchon of the Imperial German Navy led the Ottoman navy, and he acted on his own to order the Dardanelles closed, preventing supplies to the Russian Empire. Why did the Ottomans let Souchon command their navy? And I'm sure this isn't the first time I've read about such things...
Well, the case of Wilhelm Souchon really isn't a good example because this was more of an ad hoc decision/development. Vice Admiral Souchon was the commander of the Mediterranean Division of the Imperial German Navy consisting of the battlecruiser SMS Breslau and the smaller cruiser SMS Goeben. Before WWI British influence was paramount in the Ottoman navy (Ottoman ships were often British-built too) with British officers advising the Ottomans. Due to the confiscation of the new British-built Ottoman naval vessels Reşadiye and Sultân Osmân-ı Evvel still in dock by the Royal Navy, Ottoman-British relationships worsened in August 1914. (The two ships came to be known as HMS Erin and HMS Agincourt from there on.) On August 15 the naval cooperation treaty was repealed and the British officers were requested to leave the country. In this tense situation, with the war already unfolding in mainland Europe, Souchon manoeuvred his hopelessly outgunned Mediterranean Division into Ottoman waters. With British ships in pursuit, he placed himself and his ships under the authority of the Sultan. Souchon and the crews of Breslau and Goeben officially became Ottoman sailors. Gifting two German military vessels to the Ottomans, replacing the new ships "stolen" by the Royal Navy (an incident which caused much popular outrage), absolutely helped to turn the balance at the High Porte in favour of the Germans.
So let's say, Souchon's deal was more of an odd case. However, it was actually not unusual for officers to serve in foreign armies by any means. Especially non-European powers keen on developing their militaries to face imperialist ambitions (e.g. the Ottoman Empire, Imperial Japan, Qing China and many other) sought the advise of European military attachés. These officers were sent to train foreign armies in emulating European military tactics, modernising their command structure and weaponry. While the Western powers sought influence and business in non-European empires, the "influenced" on the other hand tried to get advise from what they saw as first-rate military powers. To decide which side got the better end of the deal is only possible from case to case, I guess.
The Ottomans in particular were actually quite clever to play Western powers off against each other, far from the common image of a "pawn" in the great game of Western imperialism. France, Germany, and Great Britain were somewhat equally invested in the Ottoman Empire (with the Germans being more present in the army and the British in the navy) and in mid-1914 it was in no way decided on which side of the unfolding Great War the Ottomans would end up.