I was recently reminded of a tweet I saw a few weeks ago talking about tech debt and the issues Slack went through having to pause real work for 18 months that allowed Microsoft Teams to catch up.
In my experience, this kind of thing happens when Product managers get to drive all of the tickets that a Development team does, instead of it being a budget where Product has their share and Engineering has theirs.
As a team lead now and in the past, I have always pushed for 20-30% of a cycle's task budget solely reserved for the tasks the engineering team wants to get done. This could be maintenance tasks on a database table that needs it, cleaning up the developer experience of an implementation, or removing legacy / dead code.
Those should be points that Product cannot touch. Barring some catastrophic P1 level event that overtakes the cycle, the maintenance budget should be paid.