Igneous crystals are formed when freely moving atoms in melted rock become arranged in orderly patterns as they cool. As melted rock cools, the heat energy that allows atoms to move past one another decreases, and the natural attraction between atoms causes them to stick together with similar atoms in an orderly crystalline structure.
It takes a long time for orderly arrangements of atoms to grow large enough to be seen. If melted rock cools in a short time, the crystals remain small. If melted rock cools instantly, allowing no time at all for the atoms to form orderly patterns, the rock texture is glassy.
The three cooling conditions illustrated here don't necessarily occur at the same time in a single volcano. Magma may cool entirely underground, never erupting from a volcano. If magma starts cooling slowly, forming large crystals, but then erupts, the remaining liquid forms small crystals around the large crystals. If magma does not cool until it reaches Earth's surface, small crystals form.