Mobs will try to pathfind outside of the world border, even they can't pass through it.
Related issues
Attachments
Comments

[media][media][media][media][media][media][media]

Can confirm in 1.17 pre4
Can confirm in 1.17.

Can reproduce in 21w38a:
[media]

Can confirm in 21w41a.
Can confirm in 1.18.1 and 22w05a.
Can confirm in 1.19.
Can confirm in 1.19.2.

Can confirm in 1.21 and preceding updates.

Happens in 24w35a

Happens in 24w36a