When you give any mob levitation and the hit a block they cannot move even if other blocks are around.
Steps to reproduce:
Step 1: Place a block above any mob (Not a player)
Step 2: Give that mob levitation (/effect @e[type=!Player,c=1] minecraft:levitation)
Step 3: Place blocks around the original block
They can be pushed but will not move by them selves.
I think this happens due to the AI does not allow mobs to move onto air blocks.
Unless you are @unknown or Me, you do not have legs on your head.