I believe this was a result of fixing
MC-128472 (which I found one more way to break - I already left a comment there about it). Basically, if you're swimming in a 1-tall gap or otherwise have a block above you preventing you from standing upright, you'll constantly get pushed up or down based on how far up or down you're currently looking until you're actually able to stand. I believe the reason for the momentum is that the game doesn't realize you're not sprinting forward anymore (which is normally the requirement to continue being in swim mode), so while it correctly doesn't push you along the X or Z axis after you stop moving, it still affects the Y axis.
This can make mining underwater difficult if your camera is looking above the horizon point, because the game thinks you're not grounded unless you hold sneak while not looking too far up. It's also mildly annoying being forced to bob up and down constantly if you're looking upwards at all.
Easiest way to demonstrate this bug to full effect is to make a 3x3 tower in some water while filling the middle with waterlogged cobblestone walls.
First enter a body of water, and create the main tower with this command:
Creative-fly yourself directly underneath the middle of that tower and then fill the middle:
Then /give yourself a debug_stick and set the "up" value of all the cobblestone walls to false with it (the reason for not adding up=false in the fill command is because it would only affect one wall at a time, so it's much quicker to use the stick).
Now just enter the tower, tap sprint for a moment to enter swim mode, and simply look up and down to experience the effects of this issue. The game sees that the cobblestone walls are still there, so it doesn't allow you to exit swim mode, and thus, you get to see the problematic artificial gravity in all its glory rather than just along the underside of some random blocks.
P.S. This momentum affects your gravity while swimming on land as well (but isn't strong enough by itself to lift you off of the ground). It's especially easy to tell this fact with the current 1.13-pre4 bug where you can't automatically stand back up without water (
P.P.S. This tower is also a great way to demonstrate a different bug,
MC-129773. Make sure not to confuse the main bug I'm reporting here with that one (you should only be moving the mouse once you're in swim mode, don't touch movement keys afterwards). The other report is about automatically being shot upwards due to actively moving towards walls while standing within waterlogged blocks.