I think different stages of software require different standards of quality (code you will throw out doesn’t need to be as high quality). Reminds me of Kent Beck’s 3Es (explore, expand, extract).
Often I feel frustrated with my short term speed when I focus on quality and take the time to refactor, but it saves me time the next time I work with the code. It’s a balancing act knowing when to stop based on the demands of the project.