The manufacture of soap is done by reacting oil or a fat with a base. This forms a salt. During production of soaps different types of fats can be used depending on the characteristics that are required in the soap. These can include animal tallow, palm oil and other inexpensive oils though for premium soaps even oils like olive are used.
When the base is added to the fat, first a glycerol molecule is released, which is converted to glycerin and can be left to improve the texture of the soap. The fatty acids in the fat then combine with the hydroxide ion to form soap. The hydroxide ion can be provided using sodium hydroxide, or potassium hydroxide.
This is just the basic process in soap formation; actual manufacturing requires choosing the right substances to start with and a final extraction of the soap to pack it.