Union Circle is the feature that can allow you to 4 members to come together and share a common play session. You can see each other run in the overworld, take part in raids together, and run into each other’s spawns (that includes shinies BTW) etc.
When you play Union Circle with a friend, their spawns can and will show up in the common play session. You can then go towards their spawn and catch it. When you catch it, it’ll be your OT and Origin Game.
It’s literally how the game works, and PKHeX takes that effect into account. Thus PKHeX is working as intended.
If you can’t visualise how Union Circle works, I’m sure there’s a bunch of YouTube videos you could watch.