There are different chemicals inside and when they are heated up, different color will be absorbed and thus only the ones not got absorbed will be shown. You can make them from dyes (you can get from hobby stores). Remember not to use this at home nor in areas with a lot of people.
The followings are some of the ingredients of colored smoke bomb:
White Smoke Recipe
* Potassium nitrate - 4 parts
* Charcoal - 5 parts
* Sulfur - 10 parts
* Wood dust - 3 parts
Red Smoke Recipe
* Potassium chlorate - 15%
* para-nitroaniline red - 65%
* Lactose - 20%
Green Smoke Recipe
* Synthetic indigo - 26%
* Auramine (yellow) - 15%
* Potassium chlorate - 35%
* Lactose - 26%
For more information, try:
http://www.metacafe.com/watch/933968/easy_colorful_smoke_bomb/
http://chemistry.about.com/od/demonstrationsexperiments/ss/smokebomb_5.htm