Combination of cosmic processes shapes the size and location of sub-Neptunes