It's a really good question, but hey, in the anime and in the games, we are not talking about normal trainers - we are talking about passionate and strong trainers. They are that elite which groups like Team Rocket etc fear.
But to come back to your question:
They should have a vast advantage over trainers, especially younger ones.
They do have an advantage - they are, as you said, trainers, which are familiar with their environment. But that doesn't mean they are impossible to beat.
Also, their age shouldn't play a big role in winning or loosing a battle. I believe that battling with Pokemon is like playing a video game - when you start with it you can be good or bad. The more you do it, the more experience you get, but even a guy who plays a game for 5 years can be beaten by a rookie, simply because he feels how to do it right.
To come to a conclusion:
I believe that gym leaders are strong trainers but the trainers we know are on another level than the gym leaders.