manisha5, This is an interesting question. Molasses comes primarily from the processing of sugar cane, but can also come from the processing of grapes or sugar beets. In the case of sugar cane, the cane is crushed or pressed to extract all the juice. The next step is to boil the juice, forming sugar crystals in the process.
Machines are then used to remove the crystals from the juice. The resultant syrup is the molasses. The various kinds of molasses has to do with extra boiling of the syrup. It can give you from light molasses (from the first boiling of the syrup) tot the really dark blackstrap molasses you get from the third boiling.
Molasses is used in spicy cookies and cakes when you want to add brown sugar flavor, without adding too much sweetness. Molasses has a slightly bitter taste. It is great for adding moisture and bringing out flavor.