Ask yourself the question. If you were swimming around in the water and it was your natural habitat why would you want to leave it knowing that leaving the water would kill you and your offspring.
The answer is simple - they must be suffering and the overriding impulse is to do what it takes to stop the immediate suffering it i.e. remove themselves from that environment even if a future consequence is that they can't survive.
There are mass beachings here in Australia all the time and I have a feeling that sonic and seismic exploration as detailed in the following article may be causing the whales immense discomfort or vertigo.
I don't think that they are merely disoriented because some times whales are assisted back into the water but then beach themselves again in a short period of time as if they can't stand being back in the sea.