There is no way to prevent endometriosis. But there are several things that raise your risk of developing it:
Having a close relative with endometriosis, especially a mother or a sister.
Having a short menstrual cycle -- less than 25 days.
Having menstrual flow lasting more than a week.
Having heavy flow.
Having medical condition that blocks or constricts your cervix or vagina.
Having a birth defect of the uterus, such as a double uterus or a double cervix.