They allow specific light to pass, which correspond to the emission lines from Hydrogen, Oxygen. Or block polluting sodium spectrum wavelengths. There are also red-green-blue (RGB) color filters.

Astrophotography, Pixel by Pixel: Part 5 - One Shot Color, Monochrome Sensors, and Filters

Part 5 - One Shot Color, Monochrome Sensors, and Filters