Magma forms from partial melting of mantle rocks. As the rocks move upward or have water added to them, they start to melt a little bit. These little blebs of melt migrate upward and coalesce into larger volumes that continue to move upward. They may collect in a magma chamber or they may just come straight up.