The law of conservation of matter just says what ever mass you begin with you end up with.
So if you have reactants of 1 kg of gasoline and 7kg of oxygen to burn with you will get 8 kg of water vapor and carbon dioxide as products
The 2nd law of Thermodynamics just says it is impossible to convert heat completely into work in a cyclic process.
So if you start off with a 1000 Joules of power from the gasoline and convert it to mechanical power, that only about 200 Joules will be converted to usable work and the rest will be waste low value heat