Glycerin is a byproduct of the soap making process, as you know (triglycerides in the oils we use to make soap are 3 parts fatty acids to 1 part glycerin).
When a fatty acid is added directly to a recipe (as stearic acid sometimes is, especially for shaving soaps), glycerin is added back in the same ratio (3 parts stearic to 1 part glycerin).
Sometimes glycerin can be used to mix colours, so it would be listed as a separate ingredient.
Other than for those two purposes, it could be added in a small amount to soften a hard soap or to attract a bit of extra water, but it wouldn't take much to make the soap too soft (hand-made soap already has a lot of glycerin).
Commercial soaps have glycerin as an ingredient because the fats have been broken down into the individual fatty acids and recombined to a precise recipe, so the glycerin needs to be added back in (in the same way we do when we make a shave soap) and listed as an ingredient.