When I walk with a certain orientation into a block it lets me go into swimming mode. This has happened a lot of times when going into a tree. I was able to replicate it consistently (in a different scenario) in the following videos:
Related issues
Comments

Thank you for your report!
However, this issue is a Duplicate of MC-177970.
Please use the search function in the future to prevent duplicate reports.
Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – ✍️ Feedback and Suggestions – 📖 Game Wiki