Exoplanets smaller than Neptune are common around red dwarf stars (M dwarfs), with those that transit their host star constituting the bulk of known temperate worlds amenable for atmospheric characterization. We analyze the masses and radii of all known small transiting planets around M dwarfs, identifying three populations: rocky, water-rich, and gas-rich. Our results are inconsistent with the previously known bimodal radius distribution arising from atmospheric loss of a hydrogen/helium envelope. Instead, we propose that a density gap separates rocky from water-rich exoplanets. Formation models that include orbital migration can explain the observations: Rocky planets form within the snow line, whereas water-rich worlds form outside it and later migrate inward.