Metals like sodium , potassium , aluminium have strong tendency to donate electrons while oxygen has tendency to accept electrons. This is called oxidation of metals. So, when metals come in contact of oxygen it reacts vigorously to form metal oxides.
Carbon actually is non-metal. So, it reacts with non-metals like oxygen on heating at certain temperature.