The equation for respiration is C6H12O6+6O2→6CO2+6H2O+36ATP. The chemical formula for ATP is C10H16N5O13P3. How is this possible, since it violates the law of conservation of mass because it is unbalanced?
The ATP is not actually produced from the respiration. It comes from ADP and free phosphate ions.
The production of ATP in cellular respiration happens in all parts of a series of chain reactions, and you can read more about those here: https://en.wikipedia.org/wiki/Cellular_respiration#Aerobic_respiration
Cellular respiration has four major components: Glycolysis, linking step, kreb's cycle, and the electron transport chain (ETC).
ATP specifically is primarily produced from the ETC through a process known as oxidative phosphorylation. To put it plainly, hydrogen ions are pumped into the intra-membrane space in mitochondria, then pass through channels to react with oxygen into the innermost membrane. This reaction produces water and ATP. ATP is created from energy produced from the hydrogen crossing though the channels to react with oxygen.
ATP is produced through the addition a P group to the ADP molecule, which already exist within the cell.