Context. The CARMENES exoplanet survey of M dwarfs has obtained more than 18 000 spectra of 329 nearby M dwarfs over the past five years as part of its guaranteed time observations (GTO) program. Aims. We determine planet occurrence rates with the 71 stars from the GTO program for which we have more than 50 observations. Methods. We use injection-and-retrieval experiments on the radial-velocity time series to measure detection probabilities. We include 27 planets in 21 planetary systems in our analysis. Results. We find 0.06−0.03+0.04 giant planets (100 M⊕ < Mpl sin i < 1000 M⊕) per star in periods of up to 1000 d, but due to a selection bias this number could be up to a factor of five lower in the whole 329-star sample. The upper limit for hot Jupiters (orbital period of less than 10 d) is 0.03 planets per star, while the occurrence rate of planets with intermediate masses (10 M⊕ < Mpl sin i < 100 M⊕) is 0.18−0.05+0.07 planets per star. Less massive planets with 1 M⊕ < Mpl sin i < 10 M⊕ are very abundant, with an estimated rate of 1.32−0.31+0.33 planets per star for periods of up to 100 d. When considering only late M dwarfs with masses M⋆ < 0.34 M⊙, planets more massive than 10 M⊕ become rare. Instead, low-mass planets with periods shorter than 10 d are significantly overabundant. Conclusions. For orbital periods shorter than 100 d, our results confirm the known stellar mass dependences from the Kepler survey: M dwarfs host fewer giant planets and at least two times more planets with Mpl sin i < 10 M⊕ than G-type stars. In contrast to previous results, planets around our sample of very low-mass stars have a higher occurrence rate in short-period orbits of less than 10 d. Our results demonstrate the need to take into account host star masses in planet formation models.