If the player has a motion tag but is stationary (such as being pressed against a wall), switching to spectator will carry over the motion tag, causing movement, instead of respecting the fact that the player is stationary.
An easy way to duplicate it:
Dig a 2-block hole
Spawn a villager inside
Go inside the hole
Switch to spectator mode
At step 3, the player will be forced into one of the corners as a result of constantly colliding with the hitbox of the villager. This constant pressure causes the player to have a motion tag while not moving. When the player switches to spectator mode, there is no longer any wall to collide with, so the player's motion tag causes them to go from stationary to moving.
This seems like something that could be a specific case of something more broad (motion tags not being handled well? Mob hitboxes continuing to apply the motion tag even after they should've stopped?), but I can't think of much, let alone test for them.
Thank you for your report!
We're already tracking this issue at MC-146582, so I will resolve and link this ticket as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – 📖 Game Wiki