Here is the science behind why your carrots may turn green when you bake with them, from this Food Science website
"Harold McGee, author of On Food and Cooking, explains that carrots turn green when the batter "contains too much baking soda, or when the soda isn't evenly mixed in the batter."
Carrots contain pigments that are sensitive to changes in pH balance. When the shreds of carrot come into contact with the alkaline baking soda, a chemical reaction takes place that causes the pigments to change color.
If your carrots turn inexplicably green with a recipe you've used many times before, the likely culprit is that the baking soda didn't get fully dispersed throughout the batter.
If your carrots are turning green every time you make the recipe, the ratio of baking soda in the recipe is probably off. Try reducing the amount by a quarter teaspoon next time you make the recipe.
Unappetizing though they may be, cakes and loaves with green carrots are perfectly safe to eat and taste no different than normal cakes!
Blueberries, sunflower seeds, and walnuts are also reactive to alkaline environments and experience similar color changes when the amount or distribution of baking soda is off."