Why are there age limits to becoming a pilot in the armed forces? This may be more related to the armed forces as opposed to aviation but I have to ask:  Does anyone know why most armed forces put an age limit on being a pilot in the service?  Most set the cutoff at 26-30 years of age depending on the service in question.  

One hypothesis I always had on this subject is the large amount of money that it costs to train a military pilot (2-3 million USD from basic flight training through advanced training and assignment to a fleet squadron) combined with a long service commitment (7-10 years once training is completed) where the individual must maintain good health and good eyesight to meet the medical standards required to fly and the mid 30s- mid 40s is when a lot of medical problems begin to crop up and can interfere with this.  As such the service limits the age so they enter this range at the tail end of their military flying careers.  But that's just a guess.

Another is that the competitive nature of military flight slots allow the services to be choose and only select young candidates to weed out the applicant pool.

In the civilian world there is an age limit of 65 for being a commercial airline pilot as the only real restriction to flying commercially but people frequently enter into that career in their 30s and 40s.  It does seem abnormal, if you meet the other medical requirements for the armed forces to limit a career as a pilot considering that other military occupations allow people to enter well into their late 30s or early 40s.  Does anyone have any information on this limit and the reasons why?
Largely for the same reason there is an upper bound on how old you can be to start training as an FAA Air Traffic Controller: Training people is expensive and time-consuming (flight training moreso than most military specialties), and we want to make sure we're going to get a certain number of years where the pilot is operating at peak performance out of that investment.
Combat flying - particularly in fighters - is a young man's game: It is physically demanding, and it's much easier to maintain the kind of physical conditioning required when you're younger.

Pilot contracts are also typically longer than other enlistment contracts (I believe the going term these days is 10 years of active service, after you "earn your wings"): A pilot who enters training at the maximum age (currently 28 for the US Air Force) will be 38-39 upon leaving the service, if they re-enlist for another 9 year contract they will be in their late 40s (when the natural process of aging will likely begin to limit the duties they can perform, particularly for more demanding combat roles).
Conversely if they entered at age 35 they would be 45-46 at the end of their first contract, and may already be limited by the natural effects of aging. They would be well into their 50s if they re-enlist, and while we've had active-duty pilots in their 50s they are by far the exception rather than the rule.