Wordpress used as a CMS where you build everything from scratch using built in functions and the absolute minumum number of plugins (in my experience it was exactly 1, ACF) can generate sites that are solid.
I have projects I built a decade ago that are still online, are still running and haven't been hacked.
The problem is that the overwhelming majority of WP sites aren't built like that. Because "there's a plugin for that". And you end up with these monster sites with dozen of plugins, each importing their own scripts and styles, all injecting their own crap, all bringing in their own issues. And you use those on kitchen-sink style themes that are designed to do everything and end up doing nothing well.
But that's the inevitable result when you lower the barrier to the point where one can just click buttons and install whatever.
These businesses exist and operate the way they do because of customer desires. The customers could hire better agencies but for a number of reasons don't.
No that’s on the various design agencies that sell “custom websites” and instead they just slap together a 59$ theme and a dozen plug-ins. Most customers don’t know shit about the web and they just trust the agency to do a professional job. And in my 10+ years of experience as a freelancer I’ve seen plenty of agencies taking advantage of clients.