Enterprise software tends to particularly bad because it's being sold to managers who won't use it themselves. Consumer software tends to be more user-friendly (or it won't sell), but popular software isn't always what you want.
When writing software for yourself, there is a bias towards implementing just the features you want and never mind the rest. Sometimes the result can be pretty sloppy, but it works.
However, code health is a choice. You just need to know what to ask for. A coding agent can be used as a power washer to tidy up a project. This won't result in great art, but like raking leaves or cleaning your steps or plowing a driveway, it can be satisfying.
Just as you wouldn't use a power washer to clean a painting, maybe there's some code that's too delicate to use a coding agent on? But for a project that has good tests and isn't that delicate, which I believe includes most web apps, nobody's going to want to pay for you to do it by hand anymore. It would be like paying someone to clear the snow in a parking lot with a shovel rather than hiring someone with a plow.
Enterprise software is also particularly bad because many of the customers get to demand that things work the way they want. Leading to a million weird functions, toggles, configurability because some manager in charge of making a big purchase demanded that first it must do X, many of these features left with not even a single user after the original requester leaves. While consumer software the individual consumers just get what they are given, and a single product manager/team decide what's best.
Consumer software can be good, but it's often also optimized for max engagement, not for the actual value or functionality.
Enterprise software can be because there isn't an incentive mismatch, good solution is more valuable for the customers, it will sell better and they're willing to pay for it.
But like you say, lot of enterprise software is bad because it's optimized for the payer, not the user, and it's often shoehorned to weird workflows of the particular enterprise.
* Enterprise software tends to particularly bad because it's being sold to managers who won't use it themselves.*.
Don’t forget that managers have different goals than file and rank employees.
For SaaS I work for we get requirements like required fields for a process that manager needs to have correct data and for insights into business process.
After we deliver software we get support tickets from employees that are using system nagging that “it takes too much time to fill in all this data” and that we should “fix our shitty system”.
They don’t care and they don’t have full knowledge why stuff is required - which is fault of managers that are not training their people and explaining “why”.
Oh and of course they have to copy paste shit over and over because their company won’t have budget for us integrating with their CRM and we won’t invest in something that benefits only single customer who might not renew the license next year - but also they don’t want to make a commitment like 5 years contract where we could do some investment. Of course there are some that invest in connecting the CRM but it mostly is an exception rather than the rule.