Various reasons. Antibiotic failure may occur due to: insufficient dose & duration of antibiotic; drug-resistant bacteria present, non-bacterial infection with yeast or virus; presence of kidney or bladder stones; surgical hardware or kidney abscess causing persistent infection or drug interactions preventing absorption of the antibiotic. Other diseases can mimic UTI such as: interstitial cystitis & sterile pyuria.
Cause not addressed. Antibiotics alone isn't the panacea -no antibiotic will "get rid" of the infection meaningfully unless the underlying cause is addressed. Otherwise, it will recur. A urological evaluation is needed in women if repeated infections occur (in men , it need happen only once) to determine if there is an anatomical or physiological problem that can be fixed- only then can antibiotics finish the job.