What we call sugar, the chemist knows as 'sucrose', one of the family of sugars otherwise known as saccharides in the grouping called carbohydrates. Carbohydrates, as the name implies, contain carbon and hydrogen plus oxygen in the same ratio as in water. The saccharides is a large family with the general formula CnH2nOn. The simplest of the sugars is glucose, C6H12O6, although its physical chemistry is not that simple because it occurs in two distinct forms which affect some of its properties. Sucrose, C12H22O11, is a disaccharide, a condensation molecule made up of two glucose molecules [less a water molecule to make the chemistry work].
The process whereby plants make sugars is photosynthesis. The plant takes in carbon dioxide from the air though pores in its leaves and absorbs water through its roots. These are combined to make sugar using energy from the sun and with the help of a substance called chlorophyll. Chlorophyll is green which allows it to absorb the sun's energy more readily and which, of course, gives the plants' leaves their green colour.
Historically, sugar was only produced from sugar cane and then only in relatively small quantities. This resulted in it being considered a great luxury, particularly in Europe where cane could not be grown. The history of man and sugar is a subject in its own right but suffice to say that, even today, it isn't easy to ship quality sugar across the world so a high proportion of cane sugar is made in two stages. Raw sugar is made where the sugar cane grows and white sugar is made from the raw sugar in the country where it is needed. Beet sugar is easier to purify and most is grown where it is needed so white sugar is made in only one stage.