It is entirely possible that your surgery may have played a role in your urinary tract infection.
The presence of a catheter, even atemporary catheter, increases the risk of contracting a urinary tract infection.
A condition called urinary retention is also common afteranesthesia, and can increase the likelihood of a UTI.

ntmw/Getty Images
Additionally, being immobilized after surgery will increase the probability of a UTI.
Immobility is common after trauma and orthopedic procedures including some joint surgeries.
Centers for Disease Control and Prevention.Catheter-associated urinary tract infection basics.