In the real world, shotguns are extremely capable short-range weapons. A shotgun cartridge is typically loaded with a number of small pellets, which then spread out upon firing, making it easier to hit smaller, fast-moving targets. Against non-moving targets, a shotgun has tremendous stopping power ? being hit by several pellets is exceptionally deadly. Shotguns are favored by law enforcement and home defense because of this incredible stopping power, as well as low penetration (minimizing collateral damage), and the spread of pellets makes it easier to hit than with a handgun or rifle. The ability to quickly and effectively enter a room and disable targets at short ranges makes the shotgun unparalleled at close range (within 30m) combat.
Shotguns may be loaded with slugs, which don't break apart upon firing, but these are increasingly uncommon.
In video games, and occasionally movies, the strengths and weaknesses of shotguns are greatly exaggerated. In the video game world, where enemies are either alive and fully functional or dead (for most games anyway), and simply "disabling" an enemy isn't an option, shotguns used at longer ranges basically tickle the enemy. In order to be useful, you have to move closer to the target and reach the maximum effectiveness range. In reality, this range is anywhere from 10 to 30 meters, depending on barrel length. In video games, this range is invariably about ten feet ? but when you're in that range, the shotgun is almost always extremely lethal and often kills enemies in just one shot.
The end result is that shotguns are situational weapons at best (even more so than in reality), and that using one, even in close quarters, is a risky proposition and can quickly leave the user exposed to counter-attacks from other enemies. The user will invariably be chasing enemies around the room, trying to get close enough to kill them in one or two shots, because this instant-kill nature is usually balanced by fairly rare ammo and/or slow reload, even if the use is limited to begin with.
In many cases, the shotgun has its own niche in a game's Tactical Rock Paper Scissors, outclassing all other weapons at point-blank range but losing everywhere else. Some games have your choice between a weak shotgun blast that has better range, and a more powerful attack that has virtually no range.
With "realistic" shooters being something of a current trend, this trope is on the way out, but is still seen often enough to remain relevant.