Everything was going okay, until it wasn't :(

Shikha
Hello wonderful ladies of this group. I found out today (24w, 1 day) that I might have a UTI, based on doctor's preliminary test (she has sent the sample to lab for more tests).. My symptoms for the past four days - need to go to the restroom more often and if I don't go immediately, the bladder area starts hurting. I have been given a dose of pregnancy safe antibiotics for three days (twice a day)
Would any of you have any idea from your experience why this might have happened? What can I do to clear the infection as fast as possible and also prevent any more in the future?