Bases react only with oxides of non-metal to form salt and water and neutralization reaction take place.
Magnesium oxide is a base. When Magnesium oxide was added to dilute HCl, it forms magnesium chloride and water, Magnecium chloride is basic in nature it neutralizes acid. MgO(s)+ 2HCl(l) = MgCl2 (aq) + H2O(l).
There is no reaction between MgO and NaOH, because NaOH & MgO both are basic in nature.