Before calculating one should convert all the physical quantities to their respective SI unit.
The SI unit of mass is kg. The SI unit of length is m. kg/m³ is an SI-derived unit. But cm meter is neither a SI unit nor an SI-derived unit.
Therefore 'cm' is the unit that needs to be converted before being used for the calculation.