The creature evolved a head then was slowly favored to grow a second head from scratch via selection, and so on. This means that the heads are not the same even slightly as they have evolved independently. They won't have the same kinds, size, type, function, etc of brain, or face, or anything. This would be more similar to a a creature with a sheep head and a dog head, no 2 or 3 dog heads.
Somehow a creature mutated and was born with 2 heads right away and this was selected by the environment to keep being this waypersist. Having a complex system like a head and brain just randomly be duplicated is probably so unlikely as to again be considered just impossible.
The only reasonable way this might happen is if you have a fetal abnormality that results in a chimera of 32-3 different organisms fused together. But again for the sake of reproduction, we have a problem; only 1 of them will be reproducing so again complications ariseable to reproduce because an egg cell only accepts one sperm cell. So offspring will be the child of only one of these chimera heads.
The mutation of chimeraism would have to be favored in general (even when it doesn't results in a fused chimera), and then fused chimeras would have to somehow out perform the same number of organisms as independent individual creatures for this crazy fluke of a mutation to even persist at all.
- The creature somehow evolved 3 independent brains right from the start. Developing brains is costly so developing 3 similar or identical brains is extremely unlikely if alternatives (and there are many better ones) exist. So this would probably be something more like a centralized brain and the heads are just appendages (like arms/tentacles). This is possible.
The creature somehow evolved 2-3 independent brains right from the start. Developing brains is costly so developing 3 similar or identical brains is extremely unlikely if alternatives (and there are many better ones) exists. 3 real heads with each its own brain... I can only think of sexual selection pushing this forward (like the peacock feathers) because it is otherwise so useless.
But 3 real heads with each its own brain... again maybe if they evolved all at once? I can only think of sexual selection pushing this forward (like the peacock feathers) because it is otherwise so useless. Finally the best option, the heads are not real heads but are appendages. So in this case the animal would probably have something more like a centralized brain and the heads would just be another kind of appendage (like arms/tentacles), but shaped as heads and with some of the same functionality like being able to see and being an entrance for food. This is the most reasonable but is obviously a redefinition of the term 3 heads.
So if life follows the general rules ours follows; evolution takes place over a long time, where the best at surviving and reproducing are best represented, there is almost no scenario in which multiple heads in its literal sense would ever evolve.