It has the necessary genes for either mode of life and depending on environmental conditions it turns on either one set or the other.
You're right, no intelligent design, just natural selection favoring the existence of alternate developmental routes determined by transcription factors.
These genes turn on IN water? How does it know there will be no water at the end of the gestations period? How does it know it's babies need to crawl out of the water and survive without water when the eggs are laid IN water? How does the animal know that it is a drought or wet season at the time of egg laying if the eggs are laid in water? Is it intelligent design or the animal is psychic and knows that at the end of the gestation period there will or won't be water, and its babies need to be aquatic or reptillian?