Generally speaking for MTB's you use a short (or medium in Shimano) cage if you have one or two chainrings and a long cage if you have three chainrings.
it has to cover the wider range of gears, and so compensate for the amout the chain length needs to move, long cage gives more leverage and so allow more chain movement meaning you can run a bigger ratio of small / large gears.
A road mech swings in a different arc to an MTB mech. Road mechs are really only designed to work with a maximum sprocket of 27 where as an MTB will run with a 34.
To decide on which cage length is best suited to your needs you need to work out what your total difference of your drivetrain is. To find this you take the smallest ring from the biggest ring and the smallest sprocket from the largest sprocket then add these together. So for example -
(44-22)+(32-11) = 22+21 = 43
On an XT mech a long cage has a total capacity of 45 and a medium cage is 33.
You can get away with running a medium cage on a triple set up as long as you avoid the extreme gears ie large ring to large sprocket. I always run a long on a triple as I don't trust myself.