You look at the units you want, then try to figure out which units ti multiply by to get the units you have to match the units you want. For example, if you want kg/m^3 and have m/s
You can see that you have a length/time(lets denote it d/t for distance over time) and want mass/volume (lets denote it m/d^3). d/t multiplied by time=d but we want m/d^3 so lets multiply our original d/t by time(t) and mass(m) so d/t(t) (m) =dm. However, we want m/d^3 so we will also have to divide by d^4.
(d/t)(t)(m) /(d^4)=m/d^3 = mass/length^3 =mass/volume which was what we wanted our end result to be.