Cool temperatures (around 0C) and short day length induce bolting in garlic. However, many varieties do not readily produce seed. If you induce bolting and remove any bulbils produced in the umbel, you may be able to produce a few seed.
Check pollen quality and pollen receptivity.If polen is not accepted by the stigma there is indication there may be some barrier and incompatibility operating in the species.
If you have planted garlic for its bulbs and neglect to remove the scapes, the plant is directing its energy to producing flowers rather than bigger bulbs. You can still harvest the bulbs but they will be small and low in flavor. In some regions, garlic can stay in the ground and produce a second year harvest. To reap the benefits the following year, remove the flowers and mulch around the garlic in fall. Let the green shoots die back. In spring, they should resprout and the number of garlic bulbs will increase. Pull away the mulch to allow shoots to emerge from the soil. This way you have one season where planting garlic flower was the goal, but a second season of bulb harvest is still possible. These may still be smaller than they would be without flowering but the flavor will be intense and delicious.