This is referred to as a "social trap", "social dilemma", or "multipolar trap", wherein everyone in a group can have an openly-rewarded incentive to act in a way that's against the group's common good.
"I know what I'm doing isn't great. But I do it because everyone else does too, and I don't want to lose out. Really, we all know the thing we're doing is kinda crappy, but whoever stops first just loses. After all, it's not like everyone's gonna quit at once."
Psychiatrist-blogger Scott Alexander has compared social traps to the ancient god Moloch, to whom everyone in a civilization sacrifices an infant in the name of social stability.
Resolving social traps is a primary problem of social organization — including (e.g.) labor organization, consumer organization (boycotts), and so on.