Plants are sessile organisms meaning they can’t run away. In order to survive they need another strategy - Secondary Plant Metabolites. These are chemicals that help plants to survive in their ecosystem, to protect themselves and to communicate.
Mediterranean ecosystems can be tough places to survive, one way to cope is to produce volatile secondary plant metabolites. By evaporating they can cool the leaves keeping the precious water from transpiring. They protect against UV-radiation, hungry animals and have antibiotic properties. A good example is a pine trees reaction to a beetle attack or funghi infestation. It starts to produce aromatic resin which is sticky and antifungal.
No wonder there are so many aromatic plants from the Mediterranean!
Example: Rosmarinus officinalis & Verbenone, Pinus Pineaster var. mediterranea & Pinone