It depends on the glue type, but a lack of air inside the bottle is key. PVA glue contains long molecules, called polymers, and water. When you squeeze the glue out, the water evaporates to the air, leaving just sticky polymers.
Super glue, on the other hand, contains a chemical that hardens as soon as it hits water vapour in the atmosphere.
In short, PVA glue doesn’t stick to its bottle because water is trapped inside while super glue’s container keeps water out.