It is conventional to write the electropositive atom first and electronegative atom later ,while writing the molecular formula of a chemical compound.
However it is not wrong if we write it in other manner such as OH2 or O2C, in the case CO2.
But if you specify a bond while writing, then atoms forming bond need to be specified.
eg: We can write Methyl Chloride as CH3Cl or H3CCl or ClH3C .
H3C-Cl is correct but CH3-Cl is incorrect, since the bond is between Carbon and Chlorine and not between Hydrogen and Chlorine