The short answer is scientists don’t have an answer. The longer answer is that climate change brought about by expanding polar ice created climate change that is believed to have challenged the megalodon’s survival.
From there, scientific theories have been brought forth that competition from great white sharks, a plummeting population of small and medium sized whales the megalodon fed on, and even a supernova that happened 150 light years away 2.6 million years ago all could have led to the ultimate demise of the megalodon.