When it comes to sport, age is a factor that can influence your performance. This is the sad reality of female gymnastics. Young gymnasts are light weight and very flexible, they basically can do every exercise easily. As time passes, they grow, gain weight in some cases and everything becomes much harder till one point when retirement becomes real.
Bolt once said the more older you get, the more you have to work for the same results and it becomes less and less fun.
Word Championships are held each year but Olympic Games are organized every four years. There are gymnasts who can participate once, others twice it depends on the gymnasts and her luck. If you have an injury before the games, you can wait another four years to participate and maybe it'll be too late for you as the competition you're up against is way younger than you. Most of the female gymnast retire in their late teens or early 20’s.
However, there are exceptions, Oksana Chusovitinais one exception. She's 44 years old now and participated at the Rio Olympics in 2016 ans planning to go to Tokyo in 2020 as well.
She is the only female gymnast ever to compete in seven Olympic Games, and is one of only two female gymnasts to compete at the Olympics under three different national teams: the Unified Team in 1992; Uzbekistan in 1996, 2000, 2004, and 2016; and Germany in 2008 and 2012. Chusovitina has also competed in 16 World Championships, four Asian Games and three Goodwill Games. Chusovitina holds the record for the most individual world championships medals on a single event (nine, on the vault). source
She specializes mostly on the vault, that is what she can do best. She's lucky as competing is regarded as she's 1.53 m (5 ft 0 in) and weighs 44 kg (97 lb). However, her life wasn't easy at all. She retired a few times and then cam back. In 2002 her son was diagnosed with acute lymphocytic leukemia. She along with her husband (Uzbek Olympic wrestler Bakhodir Kurbanov) was forced to accept an offer of help from Shanna and Peter Brüggemann, head coaches of the Toyota Cologne club, and moved to Germany. She continued to compete so her son could get the necessary treatment.
It's fantastic what she has managed to achieve so far. At that age must be really challenging to compete with girls half your age or even younger. She must be mentally strong to handle all the stress that comes with it.
The other example I want to mention here is a Romanian gymnast, her name is Cătălina Ponor. She won 23 Olympic, World and European medals of which 12 were gold medals. She's 31 now and retired after the 2017 Artistic Gymnastics World Championships, in Montreal, when she was 29. This is the last date but if you look at her Wikipedia page, you see for dates, which means she retired four times, some of which due to injuries.
This is understandable as many gymnasts do that. When times are tough, they give up. No one can blame them as the life they are living is tough, they are missing out on a lot. Imagine yourself living in a training center away from your family and friends, waking up early, have two training sessions a day and living on a strict diet that is more like starving. You're not allowed to go out and have fun, not allowed to eat and drink what you want.