The crystals in the rocks are produced when the magma cools down after its eruption. When the magma cools slowly, the crystals formed are larger, as they get more time for the formation. The small crystals, on the other hand, are formed when the magma cools down fast. In this case, the magma gets less time to cool, and hence, the crystals doesn't get enough time to form longer.
Hence, the rocks with crystals are produced when the magma cools down after its eruption from the volcano.