The availability of food in water, as well as the ability to avoid predators, would mean that the Ambulocetids that were able to stay under water longer would survive and reproduce.
Natural selection favored certain traits - slightly more flipper-like limbs, better swimming ability, and the ability to stay under water longer.