nitrogen in the soil gets converted back into nitrogen gas by denitrifying bacteria - they use nitrates in the soil to carry out respiration and produce nitrogen gas.
this only takes place in anaerobic conditions (where there is no oxygen) such as in waterlogged soil.