It only happens with players but can happen in both source blocks and flowing water IF the player is against a block and holding the movement key corresponding to it (i.e. if there was a block to the left of the player, they would hold left, if the block was in front of the player, they would hold forward).
The bug is a slight bobbing movement most likely caused by auto-jump.
This issue duplicates MC-102708.