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.
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.
Is the gearing indexed? That is, when you turn the shifter, does it click into place? Or does it turn smoothly? If it is indexed, that will further limit your choices. It might help if you post a picture of the shifter and the derailleur.
Read Sheldon Brown's article on gears and derailleurs. It might answer some of your questions.
There are two kinds of derailers on bicycles, rear and front.
Starting with the front derailer, since it has 3 gears you want to find one that is beefy. What do I mean by that? It must have a lot of groves to move the chain from side to side. If you look at a 2 chain ring and a 3 chain ring derailer you will notice that the former is has a smoother surface to its design. This is because it needs to move the chain less then the 3 chain ring derailer. If you still have the old derailer see if you can find one that matches the size, and if you are fitting it yourself make sure that it has just enough clearance to clear the largest chain ring. As if you have too much clearance the bike will not shift properly.
For the rear derailer it is a little trickier. Using the old one as your model you want to find a derailer that is about the same size and bends the same way. By bends I mean the amount the derailer stretches out should be consistent with your old derailer as your chain is measured to a certain length and if you get a derailer that has too little bend you could have to adjust your chain length.
Basically you want to find parts that model the parts you already have; except not broken of course. If you are not confident in picking out the parts yourself a local bike shop will always be glad to assist you in selecting parts even if you want to do the work yourself.
A genuine LBS (that does lots of workshop repairs) will hopefully have a spare rear mech for your son's bike although this may be in a plastic bag without a manual in the workshop, probably without a price sticker on it. Reason being that rear mechs on 20"/24" wheel 'youth' bikes get damaged all the time (because of how such bikes get dropped onto the pavement).
Take the advice of the LBS and ask - chances are that the workshop 'OEM part' is better suited to the bike than the fancy-boxed, priced and with manual rear mech that is in the showroom. It should also be significantly cheaper.
To make your task easier you may also want to pickup a fresh inner cable with end-cap so that the end of the cable does not get frayed. Again the LBS may sell you an un-boxed cable from the workshop supplies for less money than the packaged cable in the showroom.
Ground clearance is a big consideration with smaller wheeled 'youth' mountain bikes. Do not buy the long-arm mech if the medium length mech will suffice.