Recent observations reveal that, at a given stellar mass, blue galaxies tend to live in haloes with lower mass, while red galaxies live in more massive host haloes. The physical driver behind this is still unclear because theoretical models predict that, at the same halo mass, galaxies with high stellar masses tend to live in early-formed haloes, which naively leads to the opposite trend. Here, we show that the Simba simulation quantitatively reproduces the colour bimodality in the stellar-to-halo mass relation and reveals an inverse relationship between halo formation time and galaxy transition time. It suggests that the origin of this bimodality is rooted in the intrinsic variations of the cold gas content due to halo assembly bias. Simba's stellar-to-halo mass bimodality quantitatively relies on two aspects of its input physics: (1) jet-mode feedback from active galactic nuclei, which quenches galaxies and sets the qualitative trend, and (2) X-ray feedback from active galactic nuclei, which fully quenches galaxies and yields better agreement with observations. The interplay between the growth of cold gas and the quenching from active galactic nuclei in Simba results in the observed stellar-to-halo mass bimodality.