The mass of carbon dioxide and water that enter a plant doesn't equal the mass of sugar produced by the plant. The products of photosynthesis include both glucose (a sugar) and oxygen:
`H_2O + CO_2-> C_6H_12O_6 + O_2`
The oxygen, which has mass, is transpired by the plant. According to the law of conservation of matter the mass of the hydrogen and carbon dioxide that produce sugar must equal the mass of both the sugar and oxygen produced.
However, there's more going on than just the production of glucose and oxygen. There is water taken up by the plant that is used for the transport of molecules as well as to maintain the turgor pressure in the cells that provides rigidity. Plant growth, reproduction and metabolic processes also utilize some of the molecules used and produced in photosynthesis.