Lost my daughter at 18 weeks

On August 1st I started experiencing contractions around 6pm but took it as “growing pains”. These pains were coming & going. Fast forward to 11:30 I begin feeling gushing fluids, jumped up in told my husband that I was going to the hospital. We waited in the ER almost 45 minutes before being took to the back. Finally get to the back I’m constantly gushing out more fluids. Doctors come in to check my cervix and noticed a tear in my sac. I was leaking amniotic fluids which the baby needs to survive. OB checks it out in tells me there’s nothing they can do I’ve fully dilated. & the chances for baby survival are none due to lungs not being fully developed. I cried, cried, cried until I gave myself a headache. They had no answers to why this happened. I was perfectly fine. So I basically have to deliver my baby. It took me over 12 hours to make a decision on what I wanted to do. My heart was telling me to have faith keep pushing, my mind was restless. Not doing anything would just slim my chances for the future of having more kids or death for me if in infection was to occur. I delivered her on August 2nd. I was told a few days later that there was an infection in my placenta, but she was perfectly healthy and came out heart beating. I just don’t understand!!!!