There are many reasons that can contribute to a yeast infection, including: uncontrolled diabetes mellitus, hormonal changes, use of birth control pills, too frequent use of antibiotics, use of steroid medication, and a weakened immune system.
In your case, the yeast infection is probably caused by diabetes. Diabetes changes the pH of the urine, thus causing an environment that is good for the yeast infection. Uncontrolled diabetes mellitus also affects the immune system.
The infection might reoccur less often, once the diabetes is regulated well enough.