Color from three black and white pictures

Most scientific astronomy cameras, including the ones on the Hubble and Webb telescopes, are monochrome: each pixel only counts light, not its color. Monochrome sensors are more sensitive, because no pixel is wasted behind a color filter.
Color comes from filters. The telescope takes one exposure through a red filter, one through green and one through blue. Each is a black and white image. Assign them to the red, green and blue channels of a screen and you get a color picture.
Lining up the layers
The exposures are taken at different times, and the image can shift slightly between them as the telescope tracks the sky. Before combining, the three layers must be aligned on the stars, or every star gets red, green and blue fringes.
Narrowband: color that marks chemistry
Glowing gas clouds shine at a few exact wavelengths. Hydrogen-alpha light is deep red at 656.3 nanometers, doubly ionized oxygen glows blue-green at 500.7 nm, and ionized sulfur is red at 672.4 nm. Narrow filters that pass only those lines show where each element is. In the "Hubble palette", sulfur is shown as red, hydrogen as green and oxygen as blue, so the colors map chemistry rather than what your eye would see. Image credits usually say which filters were used.
Try it
The last step in the game's darkroom is sliding the green and blue layers onto the red one until they click into place.
Orion Nebula
Carina Nebula