Carnivorous plants trap and eat insects although they have green parts. Why?

Carnivorous plants grow in nitrogen-deficient soils, so they trap insects to obtain nitrogen and other nutrients.