No-one really knows what causes endometriosis in women.
One theory is that it is related to endometrium (the lining of the womb) being shed through the fallopian tubes into the abdomen when a woman has her period. This is called retrograde menstruation.
Another theory is that you are born with cells in your abdomen that over a woman’s life time transform into endometriosis under the influence of hormones from your ovaries. This is called the metaplasia theory.
Endometriosis can sometimes run in families and there may be a genetic connection. There are many other theories but in reality no-one really knows.