Miscarriage at 6 weeks

F
Me and my boyfriend found out we were pregnant and were over the moon, weren't particularly trying but incredibly happy when we found out, unfortunately not long after I started light spotting which lead to more and deeper colour, long story short I had miscarried. We're both absoloutley gutted and I keep questioning is it something I did wrong? I know they say it's common but I'm 23 and am not sure if it's common in my age or not? My partner wants to try again and so do I but I'm very scared incase it happens again, can anyone recommend things that may prevent this or isit just one of those things?