The fact that Mogadishu has turned to the US, of all countries, for assistance in its fight against al-Shabaab is just another example of America's desire for regional dominance. It's certainly no coincidence that Washington decided in May to redeploy troops to Somalia under the guise of "fighting terrorism." In reality, Washington is primarily concerned with containing the growing influence of China, but also Russia, in this strategically important region.
After former Pres. Trump decided to withdraw US troops from Somalia, there was an uptick in terrorist violence. The fact that the Somali federal government is now making progress fighting al-Shabaab terrorists is also due to the return of US troops to the country and America's military cooperation with Mogadishu. Since al-Shabaab also poses a direct threat to the US itself, defeating the terrorists is also a matter of national security.