The term is soiling, also known as bowel or fecal incontinence. The usual causes are related to diarrhea, constipation or weakening of the anal sphincter, which in itself can be caused by childbirth, constipation, diarrhea (catch the cyclic problem), surgery, hemorrhoids, and my personal favorite — rectal prolapse.
[Rectal prolapse is a condition in which the rectum loses its normal attachments inside the body, allowing it to telescope out through the anus, thereby turning it “inside out.” Loved that movie by the way.]
Rectal prolapse and hemorrhoids can be indirectly caused by constipation (which makes you sit and work on the toilet bowl too long), and often constipation can be caused by hemorrhoids as well — the answer to this very answer is a super cyclic medical mess which never seems to end, and keeps referring to itself. (Help.)
It is this very fact which makes it hard to solve, and the embarrassment only makes it worse.
If you want to start at the base, you need to fight diarrhea and/or constipation, which can be done through dietary changes, getting rid of stress-related issues (certainly if IBS is involved), and/or appropriate medication.
But if you are not a child (which I presume) and you are already in the rectal prolapse stage, shoving the thing back inside again and again, will not help you in the very end (pun intended). And then some surgery will be needed which will be a pain in the ass in the days right after (a double pun — what a Sunday), but which will totally change your life where it matters.