I have had two spontaneous miscarriages and later on, when I was diagnosed as having endometriosis, I was told that these events could be related. Is this true?

Not likely. Endometriosis is a condition in which the lining of the uterus is found on other internal organs like the ovaries, bladder and bowel. It can cause an problem with infertility by causing scar tissue which may block the fallopian tubes. During pregnancy endometriosis may resolve partially or completely. Talk to your md about causes, testing and treatment of recurrent miscarriage.
Absolutely not. There is no link between having endometriosis and risk of pregnancy loss. This has been shown convincingly in studies since the late 1980s. As for the converse, ("can you get endometriosis following miscarriage? ") I am also unaware that any plausible or convincing association has ever been suggested.