Nobody means for it to happen. Hostile monsters exist, they follow you into dangerous situations like going over lava sometimes. I've had a wolf follow me into the nether and die to a swarm of piglins. Its never intentional.
haha rainbow replies go brrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr