To be fair, your example does happen, even to experienced hunters, but the chances of it happening can be heavily mitigated.
Some small words of advice that I wish I'd known sooner:
- Everything you do makes noise. Some of it makes local noise (stepping on glass, startling a horse), some of it makes 'global' noise that reaches everyone on the map (firing a non-silenced gun, startling crows). If you manage your noise level well, it's much much harder for enemy teams to know where you are and set up an ambush. Of course they can still stumble on you, but you're reducing the chance.
- Don't slow down unless you know you're near enemy players. This sounds a little contradicatory with my first point, but if you're playing smart you can avoid crows and kill zombies on the move. The thing is, if you crouch or even just walk about when you could be sprinting safely, that's just giving the potential ambusher an easier shot. So keep moving quickly and smartly (going from areas of cover to other areas of cover), and you'll lessen the chance of an easy headshot.
- Know how to deal with different enemy types, and when you actually need to deal with them. This is an experience thing, but a lot of enemy types can actually be pretty much ignored. The most annoying are things like hives and immolators because they have a larger aggro range, but you can almost entirely ignore meatheads unless they're literally standing on a clue, and armoured aren't usually an issue unless they're really in your way. Still, making sure you have a melee weapon to kill armoureds and hives, and dusters/a good blunt option to deal with immolators should mean you don't take any serious damage from enemy types.
All that said, sometimes you do just get sniped out of nowhere from someone you had no idea was there. It's the nature of the game, but I'd say at least 95% of the encounters I have I was aware of the enemy team before I died, even if I did get snuck up on after the fight started. It's pretty rare I feel like I've died 'cheaply'.