Practice, but also starting to look at problems in a more realistic way. For example, I used to marvel at how one might make a simple 2D game. Now, I realize it's a lot of illusion and design based off of some pretty simple ideas. I think a lot of young developers are fearful of problems because the output seems magical.
Writing a 2D platformer this year was one of my more enlightening programming experiences. It absolutely made me draw the line between "Things that are theoretically correct (and impossible to implement)" and "Things that can be implemented easily and are `close enough'".
I thought 25 minutes was pretty mediocre for the bubble game, and re-did it without any copypaste etc (not that I had any bubble game libraries available) and was surprised it took me about 35 minutes. It was really a typing test more than anything though. Amazing that even bad students would need 20 hours for that.
What made me faster? Copy, paste, and a healthy repository of stuff to copy and paste.