Allow me to speak to these matters. Former infanteer, friends who are infanteers, boarding party members, ex-US SF doorkickers, Canadian SERT team, etc. (Still, doesn't make me an authority, just an informed amateur... standing in a bit for CoreJob since he usually covers off this stuff).
1. Shotgun
Uses: With buckshot, excellent hunting weapon or weapon for taking down unarmoured targets. Not a lot of overpenetration, esp if you use low power tactical loads or go to 20 ga. as some PDs do. That works well in urban terrain where you don't want to shoot through the walls. Police like that. They are also good weapons for civilian militias, because hunters will be familiar with them and a pump shotgun is fairly robust. With slug, they can do a whopping pile of damage, but again, armour is a stopper. With flechette, they'll shred armour (at least non-plated varieties). With dragonsbreath, they will literally destroy even plated armour, though I wouldn't want to fire too many shots (and talk about HIGH signature!). With Shok-Lok, they can demolish hinges very easily. General shortcoming: Short range, crappy antiarmour performance.
Good military uses: Good for fighting against poorly armoured enemies especially in close terrain. This can include urban, thickets, underground warrens, or the like. Autoshotgun makes a good 'room broom'. Good also for crowd control (police and military police), as they tend to be intimidating (something about a .75 in barrel that just says 'don't make the guy angry').
Issued to: SWAT, CT teams, boarding teams on ships, dockside security, police uniformed officers (backup to pistol), tunnel rats, soldiers doing MOUT (though you can use 40mm cannister, 25mm grenades from the OICW, hand grenades, shotshell adapters for the M16, etc). Also good for hunters, militia, and other irregulars with limited supply and maintenance.
2. Pistols
Uses: The pistol tends to fulfill several roles. Concealable weapon, final self defence weapon, weapon usable by law enforcement who don't need huge guns, symbol of authority (remember, an officer's pistol can sometimes be there to help keep *his own* men in line), self-defence versus crooks, etc. Pistols tend to fire slower and sometimes lighter bullets than rifles and the aspect ratio of a pistol bullet tends to make it blunter and less armour penetrative. (FN FiveSeven perhaps as a counter example). Pistols don't tend to shoot through walls below a certain power level, can often be silenced for sentry removal, are often concealable, can be very effective in CQB work either as a primary or secondary, are a good weapon for SWAT guys carrying the steel shield or other kit that only leaves one hand free, are usually sufficient for general duty policing, are often sufficient for self defence or as a deterent to crooks, and can be very deadly in the hands of a good shooter. I just watched a speed shooter get 8 rounds off into a target in just over 1 second (and no, it wasn't rimfire!). He also fired 2 shots into each of 4 separate targets in just over 2 seconds. And then fired 4, reloaded, fired 4 more into a single target in just over two seconds. I would not give this man any kind of trouble...
General Shortcomings: Don't often penetrate armour (this can be a plus, or not, depending). Damage is often less than a rifle (no, don't start arguing... this is a contestible point). Usually semi-auto, though some burst or FA capable pistols exist. Not much good at range.
Who uses: Officers, vehicle crews, artillery men, medics, security guys, armoured car guys, police, SWAT, detectives, private eyes, gangbangers, military police, tunnel rats, boarding parties, john Q public in some countries, SF sentry takedown "hush puppy".
3. SMGs
Note: SMGs are basically larger, burst or FA capable pistols with a stock and longer barrels. I generalize this to say that because they used to fire pistol ammo. So they tended to be so-so vs. armour (not very good). But, they had a bit more oomph than a pistol (longer barrel) and were a bit more accurate than a pistol. However, things have changed a lot in this area. First, there was the 'closed bolt' SMGs, and suddenly they got a lot more accurate to 50 or 75'. Then there were the Personal Defence Weapons (PDWs) firing very small hyper velocity rounds that *may* well penetrate armour, though their tissue damage capabilities aren't all that great. But they're not quite an SMG as I think of a classic one. At the same time, we've got the shrunk down rifles like the M4, the C8, and others that fire *rifle* bullets from shorter barrels and allow lots of add ons. They aren't an SMG either. But certainly, the shortened long-arm end of things has gotten busy.
Uses: SMGs (PDWs) are useful for those who don't expect to engage heavily armoured targets, who perhaps want to minimize overpenetration, who might need a suppressed weapon, who want more firepower than a pistol, who want a weapon that can work in closer quarters than a rifle or shotgun (but not so much as a pistol), and that can put out volume of fire or have a high capacity magazine. They are generally more accurate than the pistols they scaled up from, less accurate than a rifle or carbine, arguably more damaging than a carbine with the right type of ammo and versus unarmoured targets. They are good for people who need a weapon that can have a short barrel and often a folding stock.
Shortomings: Often can't penetrate armour,
not useful out over 100' really (well, some
might argue out to 150' or 200'... debatable), not as accurate as a rifle, etc.
Issued to: SWAT, customs officers, fisheries officers, some military and civilian security forces, CT operators, Spec Ops, vehicle crews (sometimes, though carbines and PDWs are moving in), officers (in some armies), and to Hollywood Action Heroes.
4. Rifles and Carbines
A carbine is just a shorter rifle. Rifles come in a variety of flavours from sniper to assault to hunting. They come in every mechanism from single shot bolt action to belt or cassette fed selective fire. And everywhere in between. Some are short carbines like the M4 that can take a billion different attachments (4 round pump 12 ga. shotgun, 40mm GL, various sighting systems and designators, a flashlight, a beanbag launcher, and I'm still missing others). Generally, they tend to have rounds which are somewhat effective against armour (less so against modern top of line heavy armours), which tend to be effective out to over 300m (sniper rifles out to over 2km in some cases!), and they tend to be the most accurate of the weapons so far. The trade off is generally weight and unwieldiness. And ammo weight. And overpenetration, if you are guys like the cops that worry about such (instead of guys like the military doing MOUT that thrive on it).
General shortcomings: Heavy. Unwieldy. (relatively speaking!). Not concealable. Harder to effectively suppress, though not impossible. The less complex versions are available to hunters and make good militia weapons.
Issued to: police snipers, general duty police as a backup especially rurally, hunters, military (infantry, snipers, spec ops), boarding parties, military police, prison tower gaurds, etc.
The problem with most of these generalizations about weapons is you can find cases where they are not true. The FN FiveSeven or FN90 will penetrate a PASGT kevlar helmet at 100m even though it is a PDW. A 12 ga. dragonsbreath shell will stave in and melt a standard bulletproof vest. Flechette from a shotgun or cannister shell will shred soft kevlar armour. A carbine can be very effective in close quarters if setup right. A pistol can be deadly out to 100m. So take all generalizations with a big grain of salt.
I hope this offers some sort of perspective. My friends in SF uses a kitted up M4, a pistol as a secondary, and sometimes a sniper rifle if the situation is such as to warrant that (up to and including the .50 Anti-Materiels type weapons). My friends in the infantry and who do ship boardings use the C7 (M16) and sometimes a 9mm pistol as backup.
Hope that helps a bit. Corejob will eventually find this thread and throw in his usual firearms wisdom.