Answer:
The heart starts out as a tube around 5 weeks and then forms 4 chambers. By 24 weeks, the fetus's heart is fully formed. However, the oxygen is supplied through the placenta from the mother's lungs. So, a fetus's heart has an extra pathway connecting the aorta (normally carrying oxygen-rich blood away from the heart) and the pulmonary artery (normally carrying oxygen-depleted blood to the lungs) called a Patent Ductus Arteriosis (PDA).
The PDA usually closes within the first 10 days of life. If it doesn't close on it's own, there's some medications that closes it. If that doesn't work, surgery is required. Some congenital heart defects (like hypoplastic left heart syndrome) become life threatening after the PDA closes.