NASA says that taking color pictures with the Hubble telescope is much more complex than taking pictures with a regular camera. The reason for this is that the telescope uses special electronic detectors instead of using film.
The finished pictures that we see are actually combinations of various black-and-white exposures to which color has been added. Sadly, this means that sometimes they play with color as a tool. The colors you see on a photo aren't necessarily what you'd see in real life.
The way they do it, is they have different filters that capture different sections of the color spectrum. For example, they will adjust their sensors to capture red light, then green light, then blue light.
This gets them 3 black and white photos. However, they each are of a different brightness depending on what color it is. In a picture of Mars, the red photo will be brighter than the others.
After they color each photo, they combine them and the result is the photos you see them publish!