Summary: there were hints from smaller studies or studies on particular groups (e.g. veterans) that flu vaccinations can reduce the probability of elderly people to develop Alzheimer's dementia. Here, almost 1 million pairs of recently flu vaccinated and not vaccinated people were matched and studied. A large protective effect was found. Other adulthood vaccinations show similar effects, hinting at a more general mechanism. There is a section about hypothesized mechanisms in the paper [0] which also points towards more general effects and not simply "avoidance of infection".
Search [0] for "Hypothesized mechanism" or even "BCG" for a concrete example of a vaccine that most likely does not act via prevention of infection (it is a tuberculosis vaccine and most people never get tuberculosis. It still shows a protective effect).
[0] https://content.iospress.com/articles/journal-of-alzheimers-... (Open Access)