After puberty, menstruation cycle prepares women's body every single month for pregnancy. If pregnancy does not happens, it ends up in menstruation(period) every month. Hormones like Estrogen and Progesterone controls both period and menstrual cycle.
Here is how it goes,
Women have two ovaries and each holds a bunch of eggs.
During menstrual cycle, hormones make the eggs in the ovaries mature. Matured eggs are ready to be fertilized by a sperm cell.
These very same hormones(estrogen & progesterone) are responsible for thickening the lining of the uterus. Uterus become spongy too so that it becomes a safe and comfy place for the fertilized eggs to start the pregnancy.
Ovulation takes place about halfway through the menstrual cycle where the hormones tell one of the ovaries to release a mature egg. Once the egg leaves the ovary, it travels through the Fallopian tube to the uterus.
If pregnancy does not happen, uterus starts to shed the thick lining as it is of no use. The lining breaks down and the blood, nutrients and tissue which builds the lining flows out of the body through vagina. This is termed as period or menstruation.
If pregnancy does happen, uterus needs the lining. Hence the menstruation stops during pregnancy.