It's horrible to have a miscarriage but it is very, very common. 1 in 5 pregnancies end before 12 weeks. You will never know for sure what caused it, but in the vast majority of cases it was because the embryo wasn't developing properly. All it takes is one cell not to duplicate 100% correctly and suddenly everything is off. It isn't anything that can be predicted or prevented.
Thank you for the reassurance. That's okay - hoping it goes well another time!