When you’re in a rush to get something done (i.e., it’s blowing up in PRD), all you can think about is getting it fixed as quickly as possible.
And then you step back, look at what you wrote and go “how could I have written this”?
So now, you’re into refactoring mode, cleaning things up and making them more optimal/stable/better for everyone involved.
Rushed deliverables are akin to working in an ER (although lives hopefully aren’t on the line) – you need to triage the issue, figure out the most important issue, fix it, and then move on to the next issue.
But at some point, you always need to come back to the initial issue – what went wrong, what do you need to fix, where do you go from here.
Same with code, yes, you might need to rush that fix, but then when the problem has been resolved, make sure to take time to get back into it, look at what is there and set yourself up for success in the long run.
Don’t let that rushed deliverable become the next thing you have to fix.