If a non-player entity is teleported to unloaded chunks using a command inside of a function, the commands that are below the teleport command are not run unless the @s selector is used. This is a bug because all commands inside of a function are run within the same tick, meaning that the commands following the teleport command should be able to run before the entity unloads.
How to reproduce:
1. Create a new world with cheats enabled
2. Create a datapack called "test" in that world with a namespace called "test" containing one .mcfunction file called "test.mcfunction"
3. Put these two commands, in this order, in separate lines of the function file: teleport @s -6900 70 6900 and execute at @s run forceload add ~ ~
4. Summon an armor stand and give it the tag "test" (using this command: /tag @e[type=armour_stand] add test)
5. Run this command in the chat: /execute as @e[tag=test] at @s run function test:test
The armor stand should then be teleported to -6900 70 6900 and should be loaded thanks to the forceload command (you can check if the armour stand is loaded using this command: /execute if entity @e[tag=test].
Now, the same steps must be repeated with a couple of changes
Enter the same world you previously created (unless you are inside of the world already)
Open test.mcfunction with an editor. Delete everything that is inside of the function file. Then, Put these two commands, in this order, in separate lines of test.mcfunction: teleport @e[tag=test] -6900 70 6900 and execute at @e[tag=test] run forceload add ~ ~
Kill all armor stands in the world and remove all forceloaded chunks. Summon a new armor stand and give it the tag "test"
Run this command in the chat: /execute as @e[tag=test] at @s run function test:test
The armor stand should then still be teleported to -6900 70 6900 and should be loaded by the forceload command. However, the forceload command does not work in this case and, therefore, the armour stand remains unloaded. This should not happen as the @s selector is selecting the exact same entity that the @e[tag=test] selector was targeting, meaning that the commands should do the exact same thing.
So from what I gather, the first command works because the @s reference is still pointing to the same entity, and thus even when not in a loaded chunk, information about it's position is available. On the other hand, the second command searches for the entity twice, first when moving it, then second when running the forceload command. The problem is, at that point the entity is no longer in a loaded chunk, and the search will only be looking in ones loaded, resulting in a failure.
I think there is a misconception that "all commands inside of a function are run within the same tick" means that they are all run at the exact same time, which is not true. The sequence is still maintained, even if the rate at which the commands executed is very high.
I feel this works as intended, and will resolve this ticket as Invalid, however I encourage further discussion on the Mojira Subreddit about this behaviour.