I'm on Bedrock PS4 1.14.41 and formatting codes don't work at all for me. I was going to make a new issue but I figured this one was relevant enough.
I've come up with a possible theory as to why this happens.
Here's how I think it works
1. Pick a random block near itself
2. Can it see the block? If not, go to step 1 (observed with fish trying to go through glass and iron bars and various land mobs trying to go through fences)
3. Does the block completely fill the space (is the block that's already there 1m x 1m x 1m)? If so, go to step 1 (observed with mobs trying to go into the same block as a chest)
4. Find the shortest route to that block, repeat until destination is reached (observed with a villager trying to find its bed but running into a wall, then moving around the wall)
How I think it should work (probably not exactly like this but sometime similar maybe?)
1. Pick a random block near itself
2. Can it see the block? If not, go to step 1
3. Does the block completely fill the space? If so, go to step 1
4. Is there any path to get to that block? If not, go to step 1 (this would be the first part of a fix)
5. Follow that path to get to that block.
6. Has it made it to its destination? If so, go to step 10.
7. Has anything new obstructed the path to that block? If yes, go to step 4.
8. Has X amount of ticks passed since trying to find a block to go to? If yes, go to step 6. (This would be a very short time to give the mob a chance to change its path)
9. Has Y amount of ticks passed since trying to find a block to go to? If no, go to step 6. (This would be a longer time to eventually stop them from trying to get to a spot it can't get to)
10. Stop moving and proceed with other things. (the eventual stopping point)
[EDIT} It seems that villagers are ignorant of the Y position of their destination (a bed for instance) if the X/Z position of their destination is closer than a path that leads them away from the X/Z before getting to the same Y. Not sure if that's a separate issue or related to this.
Somewhat related but I've currently got a chicken, a pig, and a cow trying to pathfind INTO a chest. Not on top, but in the same spot as the chest. Their heads are partly inside the chest but they refuse to move. If they were trying to get on top of the chest they would jump, but there's no jumping.
[EDIT] I just found a cat trying to get into a Soul Sand block, the same way as with the chest above. No jumping, just constantly trying to get into the same spot as the block.
@IonicEcko (I can't seem to get mentions to work correctly) The fish stop at the top side of glass and constantly spin. I had a feeling the picture wouldn't do it justice but I can't really take a short video on PS4, or at least that I know of. It's entirely possible that it is a duplicate, but I figured that it might also not be because mobs shouldn't try to go through glass to begin with. There isn't even water on the underside of the glass. So one would think fish wouldn't try to go where water isn't. It also isn't happening with any other kind of block and it doesn't happen with vertical glass. So that report might be part of this one, but the AI is still telling them to go to the underside of glass.
[EDIT] I looked at that report again but more in depth and I'm willing to bet it is part of the same thing, if not the same thing. Making it duplicate or relating to the one you mentioned seems a likely course of action.
Taken from my issue since it was marked as duplicate:
So I have a tree. It has 2 beehives on opposite sides. The leaves extend 2 blocks from the trunk. The bee was a direction from the tree not with a beehive (beehive on east & west, bee was south). It started raining so the bee tried to go to a beehive, but once it got under the leaf cover, it turned back into the rain, then it turned around to go home. It did this for a while before it got dark so all it wanted to do was go home.
I imagine what it's doing is trying to go home once it starts raining, but once it wasn't in the rain it thought to go to the flowers. But then getting out into the rain it thought to go home. Until finally it was dark so the only thing on its mind was to go home.
TL:DR the AI to go home in rain isn't active for long enough for it to go into a beehive before returning to work.
@IonicEcko Thanks. I guess I didn't search hard enough.
@IonicEcko My issue is actually neither of those. It's that if an unemployed villager has a profession (due to being traded with before losing the block) and then a block for that profession is placed, that villager isn't always selected to own that block before an unemployed, profession-less villager is.
Can confirm it is happening on PS4 1.14.41
Also affects PS4 Bedrock 1.14.41 (1.14.30)