Most of my experience has been in product-focused teams, so there is a good mixture of R&D and polish work. The company as a whole has to spend time convincing customers that our product is useful, but the development team is able to focus on actually making a useful product.
I can see how what you're saying could be a much bigger problem in a project-focused organization (or if you're working on a product that isn't actually useful). So maybe my advice is twofold: "find a good manager and stay with them, and work for a company that values software for its long-term potential."
My version of "values software" is that it be mission-critical. If it breaks, we're going to be chatting at 2 AM and testing a patch at 3, because we'd lose vast sums of money or customers by waiting until after breakfast. I met my favorite manager turning around a shop like this.
Most software is utter garbage because everyone knows better than to actually rely on it and nothing bad happens to incompetent people maintaining it.
Just making heads roll is not going to magically improve software. You can keep firing your teams but if there are other issues like unrealistic deadlines, bad process you are going to get bad output even from good people; all firing will achieve is churn.
I don't necessarily mean firing people (though there are some who really aren't good fits for this work). I mean I see better work from people who literally lose sleep over bugs, rather than merely shrugging.
I can see how what you're saying could be a much bigger problem in a project-focused organization (or if you're working on a product that isn't actually useful). So maybe my advice is twofold: "find a good manager and stay with them, and work for a company that values software for its long-term potential."