Execute as uses cords relative to the command block instead of the entity being executed
Here's an example command that if ran through a function/command block will replicate the issue.
execute as @p run summon bat ~ ~ ~
Here's an example command that if ran through a function/command block will replicate the issue.
execute as @p run summon bat ~ ~ ~