Weapons would have infinite ammo for one of five reasons. One reason would be because the weapon is so weak that the only way to compensate for its weakness is to give it infinite ammo. A few examples are the default gun in Contra or pistols in a lot of games from Rogue Warrior to Splinter Cell: Conviction. Sometimes melee weapons who in reality uses ammo like chainsaws or stun prods uses infinite ammo, because they have as an inconvenient to be used at point blank range. Another weapon that could be given infinite ammo would be a weapon that is so inaccurate or fires so rapidly that having limited ammo would be an unfair burden on the player. The best known example would be a mounted machine gun or minigun found in almost any modern shooter. The third reason would be because the player is using a cheat.
Uses for Infinite Ammo in Gameplay
Infinite ammo can be used in gameplay in a few ways. The first is retrievable ammo where the player uses a weapon, generally a bow and arrow or throwing knives, and can retrieve the ammo they fired so that they can use the ammo again. This is one of the more realistic uses of infinite ammo, even if the infinite ammo is just "virtual in this case".
Another way infinite ammo is used in gameplay is when the player must defeat an incredibly difficult gauntlet of enemies or a especially tough boss and to give the player a fighting chance, the player is given infinite ammo. For instance, the player might be given infinite ammo during the final boss fight. Sometimes that's because the player defeated a boss and acquire his own weapon, this weapon has infinite ammo, and is used for the last battles.
Strategy games often use infinite ammo to let the player focus more on unit movement or combat. Even if a few games uses an ammo system for only a few units like in the C&C series for the planes/bombers or all the units like in Earth 2150.
Infinite Ammo is also used as a cheat in many shooters. In single player, the player can get infinite ammo through typing in a code or unlocking it. This is generally accepted and many players usually use this cheat after completing the game so that they can play through the game with almost no challenge. However, in multiplayer, the player must gain the use of infinite ammo through cheating in a more illegitimate way like through the use of a trainer.