Standing directly underneath any kind of trapdoor and closing it will force the player into a swimming animation, even if there is no water near them. "Swimming" out from below the trapdoor will return the player to a normal state.
Steps to reproduce:
Place a trapdoor on the upper part of a block (at player height) so that it will close downwards
Stand directly against the block the trapdoor is placed on
Activate the trapdoor
Thank you for your report!
We're actually already tracking this issue at MC-147612, so we 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.