Not surprisingly this happens in engineering as well. You start "just trying to get it done" and when you didn't know better you just wrote it. But now that you know better, perhaps you've been bitten by an unchecked return value or a fixed length array, so now you reflexively look for those things, you fix them, you refactor them. This slows you down, and your fresh graduate peers start thinking "the old guy is slowin' down."
The only way I've found to move past this to let go of the responsibility when your manager asks you to. The conversation you have is "Boss, I can crank this out quickly but the faster its written the more likely it will have some future problem in it." then write that into the comment "Boss asked me to hack this out, said he would take responsibility date - time" and then just write it and move on. Later if it screws up you don't worry about it.
But you can't just go all irresponsible on them, you also need to think about the kinds of things your doing and step up your game in terms of what some folks called 'design patterns' make an effort to capture the way you write the things you write all the time and train your fingers to spit out an 'ok' version from the start.
Good luck.