The elves in some tropical area with little hositility in it. Maybe some island, real islands have given birth to some mighty silly creatures. Like those goats that keep passing out. It would also just slightly justify their infinite lifespan, as infinite lifespans would never evolve on a creature that dies from one thing or another within a few decades. Well they dont make sense even still, but its the only evolutionary justification I could think of.
As for elves I would think of tropical area with a LOT of hostility in it. Thats why they had to develop complex symbiosis with nature, and cooperation with others predators. (no wild animal attack elves in DF)
They also gained agility superior to other humanoids that also helps them with hunting and surviving in general. Look at Na'vi from Avatar for similarities.
As for longer lifespan, the ones whose bodies had better regeneration abilities could live longer and could gain more experience and skills because of that, which also was helping them survive.
As for dwarves, obviously mountains!
They are short and have broad bodies and lots of hair, all of that helps them survive in cold areas (and mountains are always cold).
In some other thread someone suggested that their beards help them filter dust while they dig, and I think it is a good idea as well.
All of this also explains why civilizations in worldgen stay in their favorite biome and expand no further, elves stay in forests, dwarves in mountains etc. It is because evolution made them suitable only to these biomes and they have severe problems surviving anywhere else.
Only recently dwarves have advanced in technology, learned about above-ground farming, improved their mining techniques etc. This allowed them to settle in areas they couldn't before, like plains, forests, or even glaciers!
Their old mountainhomes were only in mountains, while now their brave expeditions reach almost every place in the world! Which sometimes doesn't make the local civilizations happy, and they try to find an excuse for an open war, bringing silly demands about tree cutting etc. Superior dwarven technology also let them built great constructions, not seen before, which sometimes make other civilations jealous, and cause even more problems to the poor dwarves...
DF world makes so much sense if you think about it. ;-)