When you take a small portion of an adhesive, it solidifies after some time while the other part in the container remains in liquid state. Why does this happen?
There are many different types of adhesive, and not all of them behave in the way that you think. For example, the two components of epoxy can be left exposed to the environment for long periods of time without solidifying.
This is because different types of adhesive solidify due to different mechanisms. The adhesives you're talking about are made of a polymer dispersed in a volatile solvent; the solvent allows the polymer to flow, and the adhesive hardens once the solvent evaporates. In contrast, epoxy adhesives harden because their two components undergo a polymerization reaction.
So, in the case you're asking about, the important concept is vapor pressure. Any liquid in a closed container only evaporates to a limited extent; it evaporates until the pressure of the vapor above the liquid is equal to some equilibrium value, called the "vapor pressure", which is determined by the molecular properties of the liquid. Once the vapor above the liquid reaches the vapor pressure, then the amount of liquid in the container remains the same with time.
However, for a liquid in an open container, the vapor continually escapes. Since the vapor doesn't build up above the liquid, the pressure of the vapor is always below the vapor pressure, which means that evaporation continually happens until the liquid is gone.
There are many different types of glues and they differ not only marginally, but use different working principles. So without knowing which glue you are talking about, we can only provide generalised answers to your question.
The most common "working principles" of glues is that a chemical reaction is triggered by
- the humidity of the air,
- atmospheric oxygen, or
- the UV light (often used in industry).
You can find a description e.g. here or by googling "adhesive types".