Garlic contains sulfur compounds which can react with copper to form copper sulfate, a blue or blue-green compound. The amount of copper needed for this reaction is very small and is frequently found in normal water supplies. Raw garlic contains an enzyme that if not inactivated by heating reacts with sulfur (in the garlic) and copper (from water or utensils) to form blue copper sulfate. The garlic is still safe to eat.
If it is picked before it is fully mature and hasn't been properly dried it can turn and iridescent blue or green color when in the presence of acid.
A reaction between garlic's natural sulfur content and any copper in the water or in the iron, tin or aluminum cooking utensils can sometimes change the color of garlic.
Garlic will also turn green (develop chlorophyll) if exposed to an temperature change or is exposed to sunlight.