In the tropics, the main area of precipitation is the Intertropical Convergence Zone (ITCZ). Over the oceans and over many (but not all) land anreas the ITCZ follows the maximum of incoming solar radiation. In northern summer it is north of the equator, in northern winter (=southern summer) it is south of the equator.
In the mid latitiudes however, most of the precipitation is generated by rotating pressure systems and their asscoiated frontal systems. This low pressure belt is separated from the tropics by a high pressure belt, in which the atmosphere is more stable and convection/precipitation therefore hindered.
To answer the question, in northern summer the Mediterranean lies within the high pressure belt while in winter the low pressure influence is able to reach the Mediterranean with its fronts and rainfall. This mechanism also works for many other mid-latitude regions of the world. This is a very short answer to a complex question. There is a lot of literature about the basics of meteorology and climatology. I am sure, Wikipedia has something to say about "ITCZ" and "mid-latitudes".