Although Gym Leaders are often strong enough to hold their own opposite Elites, they rarely utilise their full potential against amateur trainers. This is because Gym Leaders aim to advance their students’ capabilities, something that cannot be achieved through obliterating their team before it can land a hit. By battling a student in a downplayed manner that specifically exploits just one of their weaknesses, the student can recognise that weakness and learn to rectify it.
For example, if a young trainer with a fast, hard hitting team showed up to a Gym, the Leader might focus on crippling said team with paralysis and then taking them down. This would show the young trainer that they had to devise a strategy to cope with status effects. Once they did that, the Leader would battle them in the same way and see if their student managed to defeat them.
A good Gym Leader is one flexible enough to challenge trainers of a variety of strengths. They must be able to target the weaknesses of an accomplished trainer, but also to show a complete novice where they need to improve. There may be occasions where Gym Leaders go all out against students - some pupils may even request that they do so, to see how well they can cope in an honest battle - but the majority of Gym matches are considerably less intense than official ones. The way a Gym Leader would battle against students and the way they would battle at the PWT would be wildly different.
This is one of the reasons why the gulf between challenging Gyms and taking on the Elite Four is so wide. Elites are not teachers, and their reputation hinges solely on their number of victories and how they achieve them. They never accommodate their opponent’s battle style. For this reason, many trainers seek honest matches with a number of Gym Leaders before requesting a battle with an Elite. If you aren’t prepared, they will wipe the floor with you.
(This is also my fancy explanation for why the Gyms get more difficult as you progress through a region. It’s not that the Leaders increase in strength, but that they fight harder against those with greater ability.)