Both processes are types of fermentation, but rotting is an undesired process, the products of which can be toxic to plants and animals, while fermented mass is full of nutrients and beneficial microorganisms.
Technically speaking, rotting is a type of fermentation, but since it is an "undesired" process, we simply call it rotting. Fermentation is an anaerobic process during which microorganisms convert complex organic molecules (carbohydrates) into simple molecules that plants can absorb easily. Rotting is a process of anaerobic decomposition, which results in incompletely oxidised metabolites (ammonia, methanethiol and indoles) that are often toxic to plants and animals. Fermented mass can be easily distinguished from rotting mass by its distinct sweet-sour smell, while rotting has a very unpleasant odor. By adding fermented mass to the soil, we provide nutrients for plants, animals and beneficial microorganisms, while rotting mass causes harm to these same organisms.