How is magma formed?