Well, from round earth theory, magma is not everywhere under the earth's crust, most of it is the asthenosphere, which is solid rock, but under the extreme conditions of temperature and pressure, this solid rock can flow, similar to lava that you see on Hawaii. Now magma, which is liquid rock, is created when solid rock is turned to liquid.
This can be done in various ways. but when it is created, it has a perimeter, thus, magma is contained.