In sandlot, I stop pressing keys and I just start moving all over the place. I can't stop moving until it stops. Why do I glitch? I mean, it only happens once in a while, but it is weird...
If you exit out of the tab minecraft holding a key to make you move and go back to the tab then you will keep going backwards if your were holding S when you left. To fix that just walk backwards. Also, if you have a remote or something connected to minecraft and its on the floor it could be moving you around? (Hope I helped!) If I can find anything else i'll tell you.
There are a lot of bugs in minecraft that are related to movement. Sometimes, exiting out of the window or getting a pop up can cause the key bindings to get "stuck". So of the bugs can be: continuing movement in a direction even after lifting up the key, not being able to move the mouse (change where you are looking) and not moving at all.