I think this is related to a vanilla bug or quirk. When players a player's bed or respawn anchor is removed (destroyed, burned, etc.), their spawn coordinates are not removed. Invalid spawn coordinates are only removed when the game actually attempts to respawn the player. This means that after a player's bed is broken, they respawn in the wrong dimension.
Reproduction Steps
Create a normal world with cheats enabled, or make yourself OP in Multiplayer.
Set your spawn point in the End. (/execute in minecraft:the_end run tp @s 0 63 0 then /globalspawnpoint set).
Teleport to the Overworld and die. (/execute in minecraft:overworld run tp @s 100 90 100 then /kill).
-> ✔️ You respawn at 0 63 0 in minecraft:the_end.
Use a respawn anchor to set your spawn point anywhere in the Nether and die (/kill).
-> ✔️ You respawn at your respawn anchor.
Destroy, drain, or otherwise invalidate the respawn anchor, so that you are unable to respawn at it.
Teleport to the Overworld and die. (/execute in minecraft:overworld run tp @s 100 90 100 then /kill).
-> :x: You respawn at 0 63 0 in the Nether (Right coordinates wrong dimension).
Bug 2
I think this is related to a vanilla bug or quirk. When players a player's bed or respawn anchor is removed (destroyed, burned, etc.), their spawn coordinates are not removed. Invalid spawn coordinates are only removed when the game actually attempts to respawn the player. This means that after a player's bed is broken, they respawn in the wrong dimension.
Reproduction Steps
/execute in minecraft:the_end run tp @s 0 63 0
then/globalspawnpoint set
)./execute in minecraft:overworld run tp @s 100 90 100
then/kill
). -> ✔️ You respawn at 0 63 0 inminecraft:the_end
./kill
). -> ✔️ You respawn at your respawn anchor./execute in minecraft:overworld run tp @s 100 90 100
then/kill
). -> :x: You respawn at 0 63 0 in the Nether (Right coordinates wrong dimension).