Some methods of preserving food are easy to understand.
For example, it's easy to see that freezing your food, or packing it in salt, would make it inhospitable to the microbes which would otherwise cause it to spoil. You might wonder, however, about jams, jellies, and preserves, all of which are protected from spoiling by a high concentration of sugar. Sugar is one of the most basic foods for all life – bacteria and mold like to eat it just as much as we do.
Sugar works not by poisoning the food-spoiling microbes, but by causing them to literally die of thirst.
This is because sugar attracts water very well; the more sugar there is in any solution, the more water it tries to draw from its surroundings. This is bad news for any microbe that happens to be inside a jar of jam. High concentrations of sugar will suck the microbe's vital water right through its cell wall, causing it to dehydrate. This process is called "osmosis," and it can be deadly for bacteria and mold.
In order for osmosis to work, the sugar concentration has to be quite high. If any water falls onto the surface of your jam, the sugar concentration at that spot might become low enough to allow mold to grow. That's why it's important to take the back up measure of refrigerating all jams, jellies, and preserves once you've opened them.
Like an oasis in the desert, condensed water dripping from the jar's lid can give a dehydrating microbe the relief it needs.