Raw garlic sprouts during storage because it's a living bulb containing an embryo that, given the right conditions like warmth and moisture, will begin to grow. The garlic is essentially trying to reproduce.
Garlic bulbs are dormant, but not dead. Each clove within the bulb contains a small embryo capable of developing into a new garlic plant. When exposed to favorable conditions, primarily warmth and moisture, this dormancy breaks. The clove uses its stored energy (carbohydrates) to initiate growth. The sprout emerges from the top of the clove, seeking sunlight for photosynthesis. Roots also begin to develop from the base of the clove, seeking water and nutrients from the soil (or, in storage, from the clove itself and the surrounding environment). The sprouting process is a natural part of the garlic's life cycle, indicating that it's still viable and capable of producing new plants. The speed of sprouting depends on factors like temperature, humidity, and the age of the garlic. Older garlic tends to sprout more quickly.
Store garlic in a cool, dry, and dark place with good ventilation to slow down the sprouting process. Avoid storing it in the refrigerator, as the humidity can encourage sprouting.