Hairspray is technically classified as a liquid when in its container, but it is often dispensed as a mist or aerosol, which can give the impression of being a gas.
When you spray hairspray, the aerosol propellants inside the can transform the liquid product into a fine mist that rapidly evaporates in the air. This aerosolization allows the product to spread evenly over your hair, but once it lands on your hair or on a surface, it dries quickly and leaves behind a thin layer of polymer that helps hold your hairstyle in place.
So, while the product starts as a liquid in the can, the way it is used gives it properties similar to a gas during application, hence the confusion. But to be precise, it begins as a liquid that becomes a mist when sprayed.