You do know they actually couldn't stop it, just deterring it and making it "difficult" for the Somali pirates to "do their business", right? The only permanent solution is either to fix up Somalia to a proper country where their people have easier jobs to choose then to join pirate gangs, or pound that Horn of Africa into the sea.
And neither option is feasible or anyone has the will to undertake, so like taking Aspirin for headache, anti-piracy expeditions is the second best option everyone is doing now.
Piracy was eradicated before without 'pounding' anything into the sea other than pirate ships.
Right now, if you are a pirate, the risks are surprisingly small. None of the Europeans or Americans or anyone else want to take captured pirates home to be tried, as they will probably just claim asylum and if anything, that might encourage more poor hopeless Somalis to become pirates.
If you are a pirate, all you have to do is toss your AK and RPGs overboard when confronted by a naval unit, most of the time, they will board you and let you go for a lack of evidence. On the off chance you are dumb enough to leave some evidence and get arrested, the navy guys will just palm you off on some African local authorities the next time they make a port stop. These local African countries wants you as much as anyone else, and will probably just boot you out of their prisons after a few weeks or months, and you can get right back into the game.
To eradicate piracy is pretty simply really. Simply adopt a take no prisoners policy on all confirmed pirates and watch as pirate numbers plummet. Just get some of the thousands, or tens of thousands of CIA predictors and reapers currently flying to do overwatch of pirate hot spots. When they see a boat with guys brandishing weapons onboard, send a hellfire their way and be done with it. It is pretty much exactly what the US has been doing for years in Iraq and Afghanistan, as well as in Yeman, Sudan and other places more recently.
But of course, pirates are non-discriminating so no single country feels directly and specifically threatened, pirate attacks are also far removed from the lives of the vast majority of people, so there isn't much public appetite any to solve the problem. No one wants to do the dirty work and have all the world's bleeding hearts on the case. But in honesty, if the UN passed a resolution or did something else to make it worth the while for a nation to pay the financial and political costs of a piracy eradication programme, any of the top world military powers can do it.
But, as I said, since no one feels like this is their problem, no one wants to do the deed and risk getting slatted in the world press after spending a tidy sum getting rid of pirates or make pirates take things personally and bare a grudge against ships and crews from the country attacking them.