I've had two known miscarriages. I was done with the heartache. My doctor ran some test and I wasn't producing enough progesterone to keep my baby alive and growing. I am now taking a natural oil called progessence plus found in young living essential oils (this is not a medication and Dr's do not prescribe it, although I informed my Dr of the oil and he wanted me to stay on it for 12+ weeks.)... I am 8 weeks 5 days pregnant with my first appointment tomorrow. Keep your head up and consult your doctor about any possible thing that could be effecting this. Trust me it's nothing you have or haven't done just like mrs_farris said. Good luck!
Miscarriages don't happen because of something you did or didn't do.
If youre not all ready taking prenatals, start. Eat healthy and exercise and keep your stress levels down.
Unfortunately, you can't prevent it :(