All commands exist in a context.
This context is first set when the command is run and consists of multiple parts that all describe the “situation” that a command is run in.
All of which can be modified individually with the 1.13+ Java as well as 1.19.1+ Bedrock execute command.
See the Minecraft wiki on the execute command for which subcommands modify which context.
When a command is run, it will get some default values depending on how it is run.
as and at (so positioned and rotated as) the player who runs it.0 0, so facing straight forward in south (positive z) direction. There is no executing entity.as and at the NPCFunctions keep the context that they’re run in.
So a function run in chat will have the same defaults as any other command run from a player in chat. The same is true for a function command run from a commandblock, it will have the same context as any command run from a commandblock would.
A command run from either the #minecraft:load or #minecraft:tick function tags will run positioned at world spawn (at the lowest end of the block, unlike the commandblock), rotated 0 0 and without an executing entity.
This allows a lot of optimization since you can use a selector once, running the function as that entity and then refer to that entity as @s for the rest of the function. It also allows for entityless raycasting as the position and rotation are preserved between function calls.
You can find a more in depth explanation on The Minecraft Wiki