The vast majority of shafts are made of steel or graphite. Graphite is newer than steel and is lighter while still being durable. Steel shafts vibrate more on impact, which can cause back and shoulder problems.
Flex is how well the shaft bends on a swing. In general, the stronger you are, the stiffer the shaft should be. Shaft manufacturers rate the flex of the clubs, but there is more than one rating system being used.
The length of the shaft is determined by the type of club and its number. In general, a taller golfer would need longer shafts and vice versa.
The weight of the shaft is determined by its length and material. Steel is heavier than graphite. A heavier shaft can provide more power on a swing, but too much weight can slow the swing.
Torque is the amount of twisting the shaft will do in a swing. The more powerful a swing you have, the lower the torque of the shaft will need to be.