Whales evolved from land mammals, but returning to land would require reversing millions of years of anatomical specialization.
What changes first
Modern whales are specialized for buoyancy, swimming and life in water. A terrestrial lineage would need major changes to its skeleton, locomotion, breathing and thermoregulation. It would take many generations and would not be a simple behavioral switch.
The physical or biological constraint
The scenario should be treated as a thought experiment. Where the consequences depend on unknown parameters, there is no single precise outcome.