It is very common for pregnant women to have urinary infections in all three trimesters of pregnancy. The bladder empties less because the pregnant uterus prevents the correct evacuation of urine and this favors infections, so it is not because you are doing anything wrong.
It is not something that should worry you excessively, but it is advisable to always treat it with antibiotics to prevent it from irritating the bladder and that by contiguity it also irritates the uterus. This mechanism is a frequent cause of premature contractions, and can even trigger a threat of premature labor, so thank goodness that there is a variety of safe antibiotics for the baby in pregnancy, so if your doctor indicates them, take them with confidence.
In women who are not pregnant, if they have a urine test with bacteria but no symptoms, treatment is not necessary. But in pregnant women, even if they do not have symptoms of cystitis, treatment is recommended. For this reason, a urine culture is usually sent in all trimesters of pregnancy. Also, if you have nonspecific symptoms, such as pain above the pubis, it is better to mention it to your doctor so that she can assess the situation.
In women who have already had more than one episode of urine infection, it is recommended that they drink a lot of fluids (more than two liters a day), that they urinate frequently without leaving a full bladder for more than 6 hours, and urinate after sexual intercourse.
It is also quite common for many women to confuse the symptoms of cystitis with a vaginal infection. Cystitis usually manifests with very frequent urination and little amount of urine each time associated with pain/burning when urinating. On the other hand, vaginitis is usually characterized by abnormal discharge (yellowish, lumpy, or with a bad smell), discomfort at the entrance of the vagina, or vaginal itching. If you have doubts about the symptoms you have, it is better to ask your specialist.