Why exactly does pneumonia cause dementia like symptoms in geriatric patients?

Fever, hypoxia. As we age, we have less "cognitive reserve". That is, environmental or mental stressors, sleep deprivation, illness, alcohol, etc impair cognition more than these factors do in young adulthood. Febrile illnesses, eg, pneumonia or bladder infection, are both common and cognitively impairing. Also, pneumonia may temporarily decrease oxygen intake (hypoxia), which also hurts cognitive function.
Low oxygen ? Elderly pts mostly present with non pulmonary signs and symptoms like confusion and disorientation and these pts have a poorer prognosis.It is probably related to sepsis and poor oxygenation in an elderly pt.
Any serious illness. Can cause confusion in any given patient, regardless of age. When that illness occurs in a patient who may have underlying issues such as circulatory problems, it can happen more often or seem more severe.