It's a bug in the programming. It's also the reason that many of the best players pull the pin before they hit an approach shot. If the pin is not in the hole when you hit the shot, you 'generally' do not get unpredictable results like that.
You can replace the pin after you hit the shot (while the ball is still in the air) if you want to see where the ball is landing in relation to the pin. The calculations for your shot are done as soon as you hit the ball so it won't affect the results if you replace the pin before the ball gets to the green.
If you lost the ball, send a help request to wgt and explain the situation. They will probably refund your ball. If you just ended up in the boondocks, take your bogie and move on to the next hole.