The same way you get good at any skill like dancing or playing a musical instrument. You just do it. Practice makes perfect. Also, read about good programming techniques because malpractice makes malperfect.
And like anything that takes skill you have two choices:
Learn to do it well, or
Learn to enjoy doing it poorly.
I've heard many people say things like "I'd do anything to be able to play the piano like that" or "I'd do anything to be that thin". The trouble is that by "anything" they mean anything but what they actually have to do which is practice, diet/exercise, etc. Unless you are a savant, developing skill at anything takes effort. As you can see we have put a lot more effort into answering your question than you put into asking it.
asking more experienced developers whether they would be willing to do code reviews could also help.
also: when finished coding, run it through a sonar cheking and see if you can solve any code-smells or issues that are detected.