So I don't know what is causing it, I randomly could not move I tried restarting my pc and it didn't help
What minecraft version are you playing at?
What kind of pc do you have?
Did you try to reduce the graphic settings?
Optifine might help to increase your performance, if that is the issue.
whoops sorry for long response but i didn't check My specs are: gtx 1650 intel I5-9300 8 gb of ram and 512 ssd (my pc is kinda trash) i also have optifine so yeah idk I also play on 1.12.2