That's because the tectonic plate that Africa sits on has been moving northward for a very long time, raising the Alps and closing the Mediterranean Sea in the process. Further east, a similar thing is happening with India, Asia, and the Himalaya. There are actually sea fossils at the top of the Himalaya mtns.
Formation of the Alps:
https://www.youtube.com/watch?v=ermI2b3S-yc
It’s important to remember that the continental shelf is part of the continental crust and not ocean floor which is largely basalt. Ocean fossils on the top of mountain ranges can come from the shelf as well as shallow inland seas.