Glue.
Actually, vinyl acetate (what common white glue is made of) is one of the common ingredients, but other ingredients are in hair spray to modify the glue to be just right for holding hair.
Hair spray needs to start out as a bunch of tiny droplets of glue that run down strands of hair until they come to the place where two strands cross. The drop stops there, and dries into a thin film of glue that holds the two strands together. Repeat this a few thousand times, and your hair will stay in place all day.
But hair spray also has to be a glue that washes out of your hair easily when you shampoo, and can’t remain sticky, and can’t become sticky on a humid day or in rain or fog. So usually a second polymer is added, one that is not water soluble. Hair spray is thus made of copolymers, which just means two kinds of glue.
The second polymer is often crotonic acid or vinylpyrrolidone.
Copolymer of vinylpyrrolidone and vinyl acetate
The polymers are dissolved in alcohol and a solvent propellant such as butane or dimethyl ether.
Plasticizers make the glue more flexible. These might be silicones or fatty acid esters (fatty acids bound to alcohols) such as triethyl citrate. There are also usually some additives that are mainly to keep the can from rusting inside, such as aminomethyl propanol or cyclohexylamine.
Hair sprays may also include emollients (skin softeners) such as cyclopentasyloxane. Dimethyl stearamine is sometimes added to reduce static electricity (by making the hair surface conduct electricity better). Many fragrant chemicals may also be added, such as Linalool, Limonene, Butylphenyl Methylpropional, Amyl Cinnamal, Hexyl Cinnamal, Citronellol, Geraniol. These are citrus and floral scent molecules.
Some hair sprays contain sunscreens such as Ethylhexyl Methoxycinnamate.