The answer is prostaglandins. These are the chemical signals girls' and women's bodies make and send to the uterus to tell it to contract, thus expelling the uterine lining at the end of the menstrual cycle. Prostaglandins aren't super picky about whom they talk to, however. If the body sends enough of them to the uterus, some stray prostaglandins will make it over to the bowel, which is located nearby. There, they also tell the bowel to contract, thus expelling… you know.