Prankster Comets are unlocked after you have 12 stars. They make galaxies crazy in different ways depending on the color of the comet. There are 5 different types. Each regular galaxy (not a ? or a boss) will have two comet stars: one for one of the first four types and one for a Purple Comet. Prankster Comets rotate regularly once they appear. As you collect stars, they will change positions; you can also feed 20 Star Bits to the Prankster Comet Luma to make them shuffle without having to clear a stage. A Prankster Comet won't appear in a galaxy unless you first collect a specific star in that galaxy (usually the star that the comet's effect alters).
These red comets make you complete a level within a time limit. This time depends on the level e.g. Dino Piranha from Good Egg Galaxy. If you are struggling, try using lots of long jumps.
These silver comets reduce you to a single life unit, challenging you to complete the level without taking any damage. The challenge is usually to beat the boss, with the exception of Lava Spire Daredevil Run from Melty Molten Galaxy. This can be extremely challenging (take Bouldergeist from Ghostly Galaxy).
These blue comets make you race a starry Cosmic Mario (or Luigi) to the star. Both cosmic characters follow preset paths to it, but each has different rules. Cosmic Mario runs a straightforward by-the-arrows path, making him relatively easy to beat. Cosmic Luigi, on the other hand, takes the shortest path to the star, employing any shortcut possible, requiring advance knowledge of the terrain and route to beat it.
Fast Foe Comet
There are only two galaxies which have this comet (Beach Bowl Galaxy and Toy Time Galaxy) which is just as well, because these yellow comets, as in the name, make foes move twice as fast (the foes in both cases being Tox Boxes). It's good if you can long-jump.
You do this once in the Gateway Galaxy before having to beat the storyline to unlock this comet. The color need not be mentioned (it's obvious) and you have to collect those little coins. Sometimes you have a time limit. Other times you may be forced down a path and must collect the coins before they're out of reach.(Purple Comets unlocks after you defeated Bowser 3 times)