Pillagers and Piglins have low shoot distance
Pillagers and Piglins can't shoot the player from far away, they can only shoot if you are within the radius of 6-8 blocks.
I think it's a bug and their shoot distance should be increase to 16 blocks as the skeletons have.
Why don't Pillager/Piglin use the crossbow more effectively?
Please add [shoot_range] tag for range mobs