This happens to me only on the Surface server and when there is a lot of lag and not just with ranged weapons either.
Essentially, what seems to happen is that, under a lot of lag, the game suddenly updates the position of enemies when you engage them in combat and this can lead to them suddenly teleporting right on top of you if you shoot them, it's actually quite consistent under those circumstances in my experience.
Similarly, if I throw a big AOE spell on a group of enemies to start combat, while there is lag, it will teleport some of them away from the main group after they get hit but they will still all take the damage.