We've found the best way to have garlic with a long shelf life is to first find a place that has good turnover. If you've ever been to any grocery or produce stores that cater to ethnic groups which use lots of garlic in their cuisines, these might be good places to start.
Farmers markets are as well, but you still need to check the garlic bulbs. This is one of a few items that can be brought to market again and again until it sells out.
A precursor to shelf life also starts with the handling during and after harvest, as well as how long it takes to get it from field to shelf. If the bulb was harvested late, wasn't dried/cured properly, sat in a hot warehouse for too long, then sat in a super's warehouse for longer before hitting the shelves, it's probably going to sprout on you. Garlic is now being imported from as far away as places like China. We've had mixed results from imported garlic. The prices are hard to beat, but the quality and taste varies.
The quality of the garlic is important as well. Solid bulb, nice tight papery cover with no mold, no evidence of sprouting at the top of the bulb. Farmers markets often sell "fresh" garlic at their stalls - I think in California it would be around June/July. You'll usually find these with the tall stalky tops still on them - somewhat dried - which will keep for at least a couple of months if stored properly.
Garlic is a bulb that is waiting to sprout given the right conditions and amount of time. LIke most other bulbs, it goes through an anual seasonal life cycle. Harvesting disrupts the part of the life cycle where cloves of the bulbs eventually start to fall away from the now-mature parent and start to sprout to form new plants, which then form new bulbs all over. The bulbs/cloves need warm soil, moisture and light to perpetuate the growth cycle.
Do the opposite - keep the bulbs in a dark, dry and cool place. I don't know about freezing them, as moisture and temps can vary in a typical freezer given the auto-defrost cycles. We usually keep them in the coolest part of our garage which is dark, cool and dry in general most of the time.
Garlic cloves are planted in the fall, when it is getting darker and the soil is moist and cold. Much of the root growth the garlic does, occurs in the fall, underground, in those conditions, not in the spring when the greens grow to send energy into bulb growth. So, to avoid garlic sprouting, don't keep it in a dark, cool and moist location, like the fridge. Instead, store in a dry, airy, room temperature spot, a small amount of light is OK. You can buy garlic keepers that you keep on the countertop. I keep the garlic I grow in the bottom of one of those wooden potato storage bins that stays in the kitchen. It has a mesh backing. The garlic keeps really well until about June of the following year to picking.
I keep mine in the spice cabinet and they end up sprouting if I keep them too long. The only solution I have is to use them before it happens. (I feel like freezing would work, but I won't be doing that.)
Though, I'd love to hear if someone else has a real way to keep them from sprouting...