As per the description of your problem, this could be due to fecal incontinence
due to the disturbance in the function of the anal sphincter muscles which tend to involuntarily contract to prevent any incontinence. You should consult with your physician so that this condition can be correctly diagnosed after appropriate clinical checkup and investigations to assess the degree and severity of this condition. Treatment will finally depend on this assessment. Hope this will help. Regards.