I know this was moved but, this is a "bug" with vanilla minecraft. What happens is your pressing a key like the "w" to move forward but then another program on your cpu comes up and pauses minecraft so you stop pressing the key but minecraft doesn't know that so when it resumes it still thinks...