The density of the liquid is calculated by comparing it to the known density of water and the masses measured during the experiment. The correct formula accounts for the mass of the liquid and the volume it occupies, which is the same as the volume of water that was initially measured.