It's a cliché that people become more conservative as they get older, which is why the right wing tends to have more old people and the left wing more young people. But it's almost obvious to speculate that it's not that people's attitudes shift to the right, but that rather, they stay steady, and the world shifts under them; that what was radical in your youth will be reactionary in your retirement, so the progression from left to right as we age is actually not a transition at all.
But I don't think that holds up to close scrutiny. The central principles we associate with the left and right wings today are very similar to what they were a hundred years ago, even two hundred years ago. Sure, we can all point to shifts. What was considered "civil rights" a hundred years ago are mostly things we take for granted now, and a new frontier of civil rights exists. When the Republican Party was founded, it was leftist and very different from what it is now. And so on. But these are the exceptions that prove the rule. Who espouses leftist doctrines changes; what they call themselves changes; what the current important issue changes; but the same central ideas are still there, year to year, decade to decade, century to century. And those are the same ideas that, as people age, seem to transition from left to right. (Not in everyone, of course, but there does seem to be a tendency, and again the exceptions prove the rule.)
The other obvious explanation is simply that as we advance through life we tend to go from less settled to more settled. In youth, our future is unsure, we don't have much, we haven't made a mark yet, we are struggling to get a foothold on life. As time passes, for most people, they progress from there to having a home, a family, a little security, a little certainty. Some people progress only a little and some a lot, but that doesn't matter: however little you go along that path, every step tends to become very important and in need of protection, because each step is hard-won. You might not even realize how strong a need you feel to protect each step towards stability you've achieved, because you take it for granted.
And yet that doesn't really well align with leftist and rightist ideologies as well as it seems at first blush. Sure, the rightist idea of protecting the right of an individual to preserve what he's earned is pretty central. But at the same time, the ideal of someone who worked his way up from nothing through hard work and ingenuity is something the rightists claim for themselves, and isn't that dream most potent for the young person who has nothing and wants to work their way up from it? The leftist ideal of protecting the individual from the abuses of those wealthier or more powerful certainly appeals more to the young who are usually neither wealthy nor powerful, but most older people are more, not less, vulnerable to having powerful organizations take away that stability and prosperity from them that they so strongly wish to protect, which is just what activist leftists are trying to stop by policing the abuses of power of big companies and organizations.
Then again, maybe the impression that people shift towards the right as they age isn't supported by the facts and is just an unfounded stereotype. I have seen some research which questions it. For instance:
I suspect that a lot more of this is about biology and chemistry, and a lot less about ideology and politics, than anyone would be very comfortable believing.