A hormone releast during delivery and nursing.
Oxitosin is the hormone. It is secreted by pituitary.
Contractions continue due to the hormone oxytocin, a few hours after delivery you can feel the top of the uterus as a hard mass in line with the umbilicus. Over the next few days/ weeks it will return to almost it's normal size. (Longer for c-sections) When you feel 'afterbirth pains'- usually during breastfeeding this is what's happening.