Magnesium nitrate has water of crystallisation and is thermally unstable that is at low temperature it gets decomposed to its oxide and nitrogen dioxide gas.
2 Mg(NO3)2 -----> 2 MgO + 4 NO2 + O2 (at low temperature)
Whereas down the group that is barium nitrate does not have water of crystallisation and is thermally stable. That is at high temperature only it gets decomposed to its oxide.
2 Ba(NO3)2 -----> 2 BaO + 4 NO2 + O2 (at high temperature)