We propose a planet formation scenario to explain the elevated occurrence rates of transiting planets around M dwarfs compared to Sun-like stars discovered by Kepler. We use a pebble drift and accretion model to simulate the growth of planet cores inside and outside of the snow line. A smaller pebble size interior to the snow line delays the growth of super-Earths, allowing giant planet cores in the outer disk to form first. When those giant planets reach pebble isolation mass they cut off the flow of pebbles to the inner disk and prevent the formation of close-in super-Earths. We apply this model to stars with masses between 0.1 and 2 M? and for a range of initial disk masses. We find that the masses of hot super-Earths and of cold giant planets are anticorrelated. The fraction of our simulations that form hot super-Earths is higher around lower-mass stars and matches the exoplanet occurrence rates from Kepler. The fraction of simulations forming cold giant planets is consistent with the stellar mass dependence from radial-velocity surveys. A key testable prediction of the pebble accretion hypothesis is that the occurrence rates of super-Earths should decrease again for M dwarfs near the substellar boundary like Trappist-1.