Hamish MacInnes, the Scottish climber, was sectioned in a psychiatric hospital because of confusion and delirium caused by an undiagnosed UTI. It took 5 years for the infection to be diagnosed and treated.
I recall with my grandmother it was almost 1:1. If she started sounding just slightly confused or slightly more forgetful than normal, my mom got her tested for UTI. And sure enough, in just about all the cases she had it.
However the first time it did indeed take quite a while before they figured out she had a UTI, and it took a few times before we figured out the pattern.
Yes, this is so scary! I know I'm just hopping in here with anecdotes but this happened to my friend's mother as well. She was seemingly getting dementia, her health got really bad, she was tired all the time, couldn't figure out what it was for a while. Eventually they figured out UTI, treated it, and all the mental stuff went away as well.
UTI almost always causes delirium in the elderly. Those with dementia go completely off the rails. When my grandma had UTI she was basically in a parallel dimension talking to her deceased parents and that kind of thing.
https://en.wikipedia.org/wiki/Hamish_MacInnes