Well unless its a full bottle, there is SOME air in it. If it just needed air, the top layer of glue thats touching air would fully harden on you.
Most glues these days are dissolved into a chemical to stabilize them so the glue can't combine with itself to harden. When they are exposed, the solvent evaporates and the glue can harden. For example with modeling glue, if you have ever used it, you'll notice it has a strong acetone smell. Thats because acetone (nail polish remover) is the solvent in it and it is evaporating now that its outside the container, which allows the actual glue to bond. In regular white elmer's glue, the solvent is actually water. They did it with water so it would be "non-toxic" however water evaporates much slower, which is why elmer's glue takes so long to harden compared to most other glues.
Most glues these days are dissolved into a chemical to stabilize them so the glue can't combine with itself to harden. When they are exposed, the solvent evaporates and the glue can harden. For example with modeling glue, if you have ever used it, you'll notice it has a strong acetone smell. Thats because acetone (nail polish remover) is the solvent in it and it is evaporating now that its outside the container, which allows the actual glue to bond. In regular white elmer's glue, the solvent is actually water. They did it with water so it would be "non-toxic" however water evaporates much slower, which is why elmer's glue takes so long to harden compared to most other glues.