First, there's a culture thing - when a company is composed out of 20 year olds, it's natural for them to prefer working with other young people who they can relate to. That 40 year old job applicant, the one with the kids and the years of experience in companies that no longer exist doesn't look as relatable as someone your own age.
Second, there's ego. In a company in which junior and even mid level managers are 25-35 years old, who wants to hire a 45 year old "veteran" that has 10 years more experience? Managing someone more knowledgeable than you is a challenge. It's much easier to get a fresh graduate and mold him into the employee you want him to be. Ego-wise, it's much nicer being the mentor than the mentee.
There are many more aspects to this and I suspect that they play a more important role than at least some of the the purely rational reasons for ageism in our industry.