When a non-metal reacts with oxygen it leads to the production of non-metallic oxides. Examples of non-metallic oxides are: CO2,SO2,etc. Usually, non-metallic oxides are acidic in nature. It is because when they are reacted with water it leads to the formation of compounds which are acidic in nature.
Example: SO2+H2O⟶H2SO3
When a metal reacts with oxygen it leads to the production of metallic oxides. Examples of metallic oxides are: BaO, MgO. Usually, metallic oxides are basic in nature. It is because when they are reacted with water it leads to the formation of compounds which are basic in nature.
Example: MgO+H2O⟶Mg(OH)2