I think you're right on with the anal glands. There are sacs on either side of the anus that these glands fill with the fluid they manufacture. It's believed that it may have been a protective measure many, many years ago, like a skunk. Many cats can voluntarily empty their anal sacs, squirting out a pungent fluid, to this day.
If production of anal fluid is normal, most of the fluid is squeezed out of the sacs when your cat passes stool. Cats with consistently soft stool, therefore, may have a problem with emptying out the sacs involuntarily. Feeding a diet a little higher in fiber (like hairball formulas) may help. Even cats with normal stools may express the fluid if they're frightened, straining (like in grooming), or if there is any pressure on the anal area.
A lot of cats whose anal glands become impacted will scoot their bottoms along the floor to try to express the fluid. Your vet can express the sacs when needed. He can teach you how to do it at home, too, if you're brave enough! It's a very smelly, dirty task. Cats with chronically impacted sacs or overactive anal glands may be good candidates for having the glands surgically removed, since impaction can lead to painful infection.