Blood clot caused miscarriage?

I’m having recurring early miscarriages. This last one I found out a huge clot had formed near the gestational sac and it caused me to miscarry. Does anyone know how these clots can be prevented from happening? I feel like the transvaginal ultrasound I had caused the clots because I was fine before but started bleeding after.