Two reasons why the process of canning food kills microbes?
Heat or air
Canning is an important and safe method for preserving food if used properly. The canning process involves placing foods in jars or similar containers and heating them to a temperature that kills microorganisms that cause food to go of. During this heating process air is forced out of the jar and as it cools a vacuum seal is formed. This vacuum seal prevents air from getting back into the product bringing with it contaminating microorganisms.
because the jam is heat treated before sealed and so has no microbes on it, even when you open it the high amount of sugar dries out the microbes, which then kills them (see below) the sugar is a solute and the jam is the solution. also jam is viscous so it slows them down while the sugar kills them