Why do some people (mainly old people) get delirium when they have a UTI? How does that happen? Why?

Out of balance. You hate to think of it this way, but when we get old the body (and mind) can become very frail. Many older folk have shrinkage of brain tissue/ some elements of cognitive decline whether it is recognized or not. Add a UTI to that and u can really throw your patient for a loop. With younger folk u rarely see this unless very severe-like sepsis. Once UTI is well treated, expect patient to recover.
Confusion. The elderly, particularly those with dementia, may not be able to tell you about urinary burning, increased urinary urge, or lower abdominal pain that is often reported in younger adults with UTIs. Fever might not occur in the elderly. This can lead to confusion and delirium.