What is fermentation and why does it preserve food?
Fermentation is the controlled conversion of sugars and starches by microorganisms — bacteria, yeasts or moulds — into acids, alcohol or gases. It preserves food because those products create conditions in which spoilage organisms cannot survive.
The main mechanism is acidity. In lactic acid fermentation, bacteria consume sugars and produce lactic acid, dropping the pH. Most spoilage bacteria and pathogens cannot tolerate a pH below about 4.6. This is how sauerkraut, kimchi, yoghurt, sourdough and traditional pickles keep, and why they taste sour: the sourness is the preservative.
A second mechanism is alcohol, produced by yeasts in beer, wine and cider, which is inhibitory at sufficient concentration. A third is competitive exclusion — a large, established population of harmless organisms simply crowds out anything that arrives later.
Salt is usually involved, not as the preservative itself but as a selector. A brine at the right concentration is tolerated by the lactic acid bacteria you want and not by much else, letting the right organisms establish first.
Fermentation also changes food in ways that have nothing to do with keeping it. It generates flavour compounds that do not exist in the raw ingredient — the difference between milk and mature cheese, or cabbage and kimchi, is almost entirely fermentation. It breaks down proteins into free amino acids, which is why fermented foods are strongly savoury. And it can improve digestibility, as with the lactose in yoghurt.
Vinegar pickling is different: it adds acid directly rather than growing organisms that make it. Both produce sour preserved vegetables by quite different routes.
Home fermentation needs clean equipment and a reliable recipe, particularly anything low-acid.