A lot of research has been done on this. The truth is that there seem to be too many factors involved, such that no single factor can be blamed in most cases. The heart is formed in the first 2 months of pregnancy. Hence what happens in that period alone determines how the heart is formed. Some factors thought to play a role include genetic mutations, maternal diabetes, certain medicines taken in first trimester and invitro fertilization.