Or just keep standing until you got the hang of it. Make sure you have the better position to begin with to avoid having to rely on luck. (Edit: This paragraph looks odd in this context. It was written at the same time as the post above, so don't take that one into account when reading

)
More detailed explanation:
Each weapon has a random deviation that simulates the soldiers ability to hold the weapon steady as well as other factors such as ballistics (although that does not matter on such close ranges of course).
Therefore, moving around much makes your weapons less accurate, while standing still (or better yet, lying prone for a while) adds to the accuracy. If you have a bipod and deploy it (and don't move for a while), it'll get even more accurate. However, when you move, your accuracy gets worse. The more "mobile" your stance, the better you are at shooting while/after moving.
So, if you were standing, then move a few steps, and stand again, you'll only have to wait a second or two and will be accurate again, since you were in a mobile stance. However, if you were prone or had a bipod deployed and then moved, you'd be a lot less accurate. The worst things you can do is sudden moves such as jumping or going prone suddenly, that completely screwes up your deviation.
Try to move slowly and take a moment before you shoot. Don't shoot too rapidly, and don't jump/go prone in the middle of a fight. Rather go prone BEFORE you shoot, then wait a while (at least 5 seconds), and then you'll be very accurate.
("Slow is smooth and smooth is fast", as the saying goes)