How do I know which derailleur I need? The derailleur on my sons mountain bike is mangled, how do I know what to replace it with?

I understand they aren't one size fits all.

There are 6 sprockets on the rear cassette and 3 on the front.
If you have a six-speed rear cogset the bike is either inexpensive or seriously old; such things have long since been replaced by 7-8-9 or 10-speed gearsets.

At any rate, the important thing with a rear DR is "capacity".  It must have sufficient arm length to handle the range of gears on the cassette or freewheel.
Most all DRs have sufficient side-to-side movement, so the factor you're looking for is the length of the "arm" with the two rollers on it.
Longer arm, more capacity.
If you look at high-end road bikes with very "close" gearsets, you'll see the arm is very short.   Look at mountain bikes which have great big low gears, and you'll see longer ones.

Also... Cheaper DRs such as found on many "box-store" import bikes often mount on a steel piece that is bolted into the dropout. (where the axle goes) 
Better DRs mount on a "hanger" which is often replaceable; these may have a different mounting screw. 
Just take the old one with you to the bike shop and they should be able to find a good replacement.