It's because the bullet is dying before your second script can record its properties accurately.
_posx = (getpos _this select 0)
_posy = (getpos _this select 1)
_posz = (getpos _this select 2)
Before these lines are reached, the bullet has already died and its position is now [0,0,0], and any particle effect will be created there.
Remember, OFP's bullets travel at 900m/s, so even at 90fps a bullet will already have moved 10m in a single frame.
By recording the bullet's position before the script begins (in an .sqf function run directly from the eventhandler), I was at least able to ensure that the particle effect always appeared. (See attached mission). However, it still appears several meters away from its actual impact point. That's because it dies at least a frame's-worth of movement away from its last recorded position. That's why the particle effect appears on the gun barrel if the bullet lands close (its last recorded position was leaving the barrel).
Using mathematical skills which I lack, it should be possible to approximate the impact point of the bullet much more exactly by taking its last known heading and position, and asking the engine to "draw" a ray from there to the ground. I might think of something.