it attaches the baby to the placenta which is what sends all the blood and nutrients to baby and takes the waste away.
The placenta is on the wall of the amniotic sac and when baby is born the placenta and sac are 'born' afterwards. Thats the afterbirth. So once baby is born you still get more contractions and then give birth to the sac. This can take an hour or so or it can be sped up be means of an injection given to the mother.
The sac is checked afterwards by a midwife to ensure it has all come away, as any left inside mum can cause infection and heavy bleeding.
When baby is born, their first deep breath causes a valve in their lungs to close, this valve leads to the umbilical cord and once sealed the cord will just die off. Thats why it goes black and shrivels before falling off leaving a nice belly button.