|MadSci Network: Earth Sciences|
First, you must remember that Earth isn't just a solid ball where everything sits still. It is constantly in motion, with the plates of the crust sliding against one another, being driven upward, being driven downward. Pressure deep in the earth is generating heat, so there is always magma being formed as rock is melted. Now, as for why volcanoes do not erupt all the time, it is because a volcano can be thought of as the planet's "relief valve." Magma presses its way up against a weak spot in the crust, and when it finally breaks through, it spews out for a while until the local pressure decreases. Once the force of the eruption slows, the cooling magma solidifies into rock, and the whole thing dies down... ...until later, when the pressure builds up again, and the magma starts looking for a way out once more. Think of it as blowing up a balloon. You can only puff so much air out into it before you just don't have any pressure left inside.
Try the links in the MadSci Library for more information on Earth Sciences.