Changes to their surroundings can trigger “rapid evolution” in species as they adopt traits to help them survive in the new conditions, a study shows.