Just a guess, but it looks like the body is producing a defense against something recently recognized. If there is a challenge to the bowels, there are cells which will produce protein matrices which surround and capture certain foreign things seen as dangerous or a nuisance to the body. They work like antibodies, and are generally accompanied by mucus, but not always.
It may produce a cloudy and sometimes stringy structure around the foreign material. It may be that there is a microscopic parasite within this mix, or particles and waste from a larger organism like helminths (assuming the circumstances are related to classic symptoms of latent parasitic infection).