The bug
Pillagers and vindicator walking on the top of kelp blocks or sea grass at the surface of the water can't swim away nor find their way out, just get stuck there and start dancing around.
[media][media]Related issues
Comments
After more playtime, I think this is not related to where they spawn, but more to their path finding.

Confirmed. While Vindicators and witches during a raid try to find a way to a fenced village and they move to water they're just spinning around there forever. Even when I attack them, they're just spinning and spinning. However only vindicators and witches, pillagers never do this.

Duplicate of MC-136318. Please use the search function before reporting.
Can confirm. Pillagers also sometimes spawn in the ground.