However, in other games it is in the rules but somehow violates the spirit of the game. Star Trek and Star Wars come to mind. How many characters on TV or in the movies run out of ammo? Only when the plot calls for it.
Most games will fall someplace between the two extremes, such as any d20 game. Where the amount of ammo does not seem relevant, I prefer to use a different mechanic. In a modern setting with characters carrying normal firearms, I assume that all characters and NPCs are spending a bit of their time reloading as the opportunity presents. This means they almost always have bullets available.
To add some tension, if the character fails their attack roll by rolling the worst possible number (say, a 1 in 20) then they are out of ammo and need to spend time to reload right now. If the rules have a mechanic for a jammed gun occurring on a one, the first time they roll a one they are out of ammo and if it happens again on the very next roll, the gun has jammed.
Some games have weapons that simply don't work like a machine gun or semi-auto pistol. A blaster in Star Wars or Phaser in Star Trek are very unlike modern firearms. In the movies, they never run out of ammo unless the plot calls for it. As before, if a character rolls a 1, their weapon has malfunctioned. It makes a noise and nothing happens. To get the weapon working, the player needs to make a successful to hit roll to make it start working again. That seems like an oxymoron rule and maybe it is. The tension comes from the fact that the enemy knows there is something wrong and the hero can't shoot. They are drawing attention to themselves. Having the weapon suddenly go off in the enemy's face is just like Star Wars. And in Trek, fiddling with the controls almost always works.
On the off chance these advanced weapons experience two back to back failures, then they are out of action until a repair is made, usually outside of combat.
For most games where ammo tracking is important, I make sure the story provides ample reloads or parts where shooting is not required. My D&D players love "defending the castle walls" because by their nature, defenses have plenty of ways to get more ammo to the defenders.