BV whyyyy

I have bv and went to the ER I was given flagyl but I just wanna know how did I get it could it be from douching...well I know but that's all I can think of I'm experiencing cramping please let me know