Super Wally, when did that happen?
After Beating the Battle Maison Super Rank a bunch of times in ORAS, Wally upgrades his team to arguably the strongest team in the pokemon series single player, it's pretty easily dismantled in Shift battle, but on set battle, the dude is kind of a monster.
It can only take you so far. Set only takes away your free switch, and even then, the AI isn't advanced enough to punish players for switching out. There's really nothing stopping one from switching after the AI throws out their Pokemon. Sure you lose the free turn, but again, the AI isn't that advanced enough to punish you for it.
And at this point, what can you do to make the AI better without cheating (aka knowing exactly what you'll switch into)? The only way to make a good pokemon single player battle is to have the trainers run a single strategy to be countered by the player and have 6 pokemon, AI changes would simply have to be either in pursuit of the strategy or hitting a weakness that the player would have the sense to counter in some way. That's it, and it would be wholly satisfying to the player, I assure you. Routes and caves would be designed to wear down the player and the gyms test individual strategies associated with type. I rather enjoyed the Sinnoh gyms because of this idea.
On the topic of AI, It took decades to get chess AI to a competent level and even more years to get them to beat grandmasters and chess had hundreds of years to get all the metagame knowledge it needed. Now Pokemon is definitely not as in depth as Chess but the metagames and mind aspects of out thinking the other person are similar aspects. It's just not a reasonable expectation from a single player turn based series to ask AI of that level to run prediction algorithms and be an enjoyable experience in single player. (Not regarding the fact that most "AI" in games is actually complex Scripting to begin with)