PLEASE, remember that: random mutation will not kick in IF there is no
new ecological challenges. That is the post of RAZD and caffeine.
You're misunderstanding. Mutations do no happen in response to the environment.
Mutations happen all the time. Whatever is going on in the environment, every single organism ever born has many mutations.
Most mutations have no noticeable effect. Some do. Some of these effects are harmful. Some are good.
And this is where the environment comes in. Whether a trait is harmful or good depends on the environment.
Let's take a real world example. These are guppies (
Poecilia reticulata), a very popular aquarium fish because you can breed them in all sorts of pretty colours. The plain one of the left is a female. The pretty coloured one on the right is a male.
Now, let's say a guppy is born with a mutation that makes him brighter and more colourful. This isn't in response to the environment - it's just an error in copying his parent's genes that happened before he was born.
This bright colourful guppy stands out for a mile, and he is noticed very quickly by a big hungry fish, and becomes lunch. He doesn't pass on his bright colourful genes. His mutation was bad, and the environment, in the form of a big hungry fish, determined this.
Now, let's imagine that another guppy has been born with a very similar mutation, but he is born in a different place. He's born in a quiet little stream somewhere, where there aren't any big fish to eat him. This bright, colourful guppy grows to be big and strong, and all the lady guppies think his bold, bright colours make him look like a big hunk of gupy man flesh. This guppy becomes a player, sleeping around with all the lady guppies he can get his fins on. He leaves a trail of baby guppies all over the stream, meaning that the next generation are full of bright, colourful guppies like him. In this environment, his mutation was a good thing.
The environment didn't cause either mutation. The mutations just happened. It's just that whether or not the mutation turns out to be a good thing and get passed on, depends on the environment it appears in.