For whatever reason allays are attracted to floor/ceiling trapdoors and get “glued” to them, spinning around on the spot. This state is not permanent though but happens pretty regularly and last for considerable amount of time. Looks to me like pathfinding issue.
Environment
Tested on 1.21.11. Creative Mode.
Tested in Survival - same behavior.