Are gym masters easy to beat? Gym masters are dedicated to train their Pokemon and and are very familiar with their environment. They should have a vast advantage over trainers, especially younger ones.

If that is the case, why don't they defeat more trainers? Shouldnt only trainers with comparable experience defeat them? Ash can defeat much older masters who have been training for decades. Is it just to advance the story or is there a rational explanation?
They are not easy to beat, Ash isn't just your average trainer. He might seem stupid/have really weak pokemon sometimes, but he is kind of world class when you look at some of his greatest accomplishments. And many gym leaders do beat him, and he eventually comes back to win. Gym masters do beat most challengers, just beating all of a region's gyms is qualification enough to take on the Elite four. 

Also, gym masters are normally trainers who work within the rules of the gym, a fighting master tends to mainly have fighting pokemon, so will always be at a disadvantage to a trainer who wanders in with a bunch of psychic/flying pokemon. They are never portrayed as invincible or easy, just a bunch of tough trainers, well above the average guy wandering around with a bunch of pokemon.