So, Bacterial vaginosis is very common and won't cause infertility but is sometimes found in correlations or conjunction with infertility. You should take whatever antibiotic the doctor prescribes as you are not yet pregnant and if it persists, have your husband take a course of therapy as well (as a male and female can pass it back and forth during sex). This is assuming you have simple BV and it isn't left untreated and you've got PID (pelvic inflammatory Disease). PID is pretty rare and women are generally very ill when they have that, so you'd know and it's doubtful you do/did have this. I do understand that there are some studies out there that looked at women with unexplained infertility and if they have BV and some do. But it's not well studied enough to make that correlation and BV IS treatable. Flagyl is the normal course of therapy.
Here is some information on bv for you. https://www.mayoclinic.org/diseases-conditions/bacterial-vaginosis/symptoms-causes/syc-20352279 Don't douche, (ever), quit smoking if you do, wear cotton undies and change whenever damp (like after exercising), take a good probiotic.
Miscarriages can be random and one in four pregnancies end in miscarriage. This doesn't make you feel any better though, I'm sure and sorry for your loss! Or should I say losses. If you have any more miscarriages, I'd see a fertility specialist. Let us know about your journey, we're here to support and talk!
Do you track your cycle through temp taking?
The link is really awesome for information.
I wanted to add that complications from BV are not common. But they are possible. If BV is left untreated and does not heal on its own, BV can spread to the reproductive organs and may lead to pelvic inflammatory disease. In its turn it may also increase your chances of becoming infertile. If a woman develops PID because of infection with BV, an ectopic pregnancy is more likely. BV during pregnancy can also lead to complications including premature birth and low birth rates. If you do end up using over-the-counter medication for a yeast infection, and it turns out you have BV, your BV symptoms may get significantly worse. Your doctor will likely give you a prescription for antibiotics to treat the BV infection. When it comes to intercourse, the same principles apply as to yeast infections. Since the side effects of a BV infection are more serious and can cause pregnancy complications, see your doctor to diagnose these issues. Hope this helps. Take care.