It might seem odd if a cocktail recipe calls for the drink being shaken and not stirred, but there's good reason for it. Here's how shaking or stirring a cocktail can change its flavour and consistency, and when you should do each method.
As this video from the Cocktail Chemistry YouTube channel explains, the main purpose of both shaking and stirring cocktails is to cool and dilute them. Beyond that, both methods of mixing have their own subtle nuances.
When you shake a cocktail, for example, you're also aerating the drink, changing its texture. When a cocktail calls for juice or citrus, it's usually best to shake it with ice for about 15 seconds.
Stirring, however, is used when you don't want to over-dilute, over-cool, or change the texture of a cocktail. So it's best for spirit-forward cocktails like a Manhattan or martini where the flavour of the spirit is what makes the drink shine. Unlike with shaking, though, the ice you use to stir a cocktail actually matters. Small ice cubes will cool and dilute the drink faster, and large ones will cool and dilute the drink slower.
Getting Started - Shaking vs Stirring [YouTube]