If you hit an entity while swimming underwater, the player will stop swimming for a brief moment (it changes the size of its hitbox to the one it has when it is standing and returns to the swimming one) and then get stuck in the middle of the water if they try to swim below a block (the player gets stuck when their large hitbox collides with a block, even if they are using a different size hitbox).
Steps to Reproduce:
1. Go to an aquifer (flooded cave)
2. Underwater, spawn an entity:
3. Swim while holding W + Ctrl (don't release these keys)
4. Hit the entity (you will see that it stops swimming for a moment)
5. Try to reach the ceiling of the cave (you will get stuck a block away from the ceiling)
If you release these two keys, it will work normally again.
You can also reproduce this in third person with the hitboxes turned on (F3 + b), and you will see the quick hitbox change that it does when hitting the entity.
Watch Bug with hitboxes on.mp4 to understand this better.
The bug can also be triggered when exiting the water in certain circumstances (if there is one block of air between the roof and the water and a block next to where the player comes out) and can cause damage to the player when colliding with a block. (Damaged when exiting the water.mp4)