Nonlinear dynamics and magneto-elasticity of nanodrums near the phase transition