As has been pointed out, garlic sulphides can react and change to a green/blue colour and it's a normal reaction in the presence of acids. It's an ordinary amino acid reaction, started when garlic is broken down, which releases thiosulfinate compounds that react with the amino acids. It's an indication of the age of the garlic as older garlic will produce a stronger reaction, and is usually exacerbated if the garlic picked before maturity. So you probably got very young garlic that had been stored for ages.
The other option is a copper sulphate reaction, however seeing as the reaction only took place after cooking, it indicates an ordinary amino acid reaction instead. Copper reactions are negated by heat, and iodine reactions in table salt (which is another culprit) requires considerable amounts of salt. This however might be the culprit as excessive salt is used to mask the natural bitterness of preservatives in pre-packaged food. However the reaction you have is a conjugated one, indicating that it was a simple amino acid reaction with thiosulfinate compounds.
It is safe to eat. In fact the Chinese intentionally induce the reaction for celebratory feasts. Colour changes in garlic don't indicate that any harmful reactions have taken place. In fact botulism poisoning (which is very common with garlic preserved in oil) won't show any visible indicators and is the only poisoning attributable to garlic. Never store garlic in oil, ever! Never make garlic oil, ever! Garlic will also reject poisonous mould build ups, but it's usually mixed with other ingredients which can form mould, not the garlic itself. In terms of storing food cooked with garlic, be very careful about the amount of fat in the cooked material as it can also result in botulism poisoning...