When underwater and swimming, upon swimming on top of the bed, since beds are not waterloggable, they provide an air socket. However, while in the air socket and sleeping, you see your body from normal sleeping perspective laying down. You then sleep with the normal animation. This bug isn't particularly world destroying, but its a bug nonetheless.
This appears to be a duplicate of MC-187784, which hasn't yet been resolved. If you have any additional information to provide regarding this issue, feel free to comment on the parent ticket. If you feel that this issue is affecting you, feel free to vote for the duplicated ticket, to give Mojang a basic idea of how many people are impacted by the problem. Just to further inform you, this will not determine how quickly the bug gets handled or fixed.