First we will discuss about what makes an object to float or sink ?
If the density of an object exceeds the density of water, object sinks.
If the density is lesser than water, object floats.
Human feces are primarily made up of water, undigested food, various bacteria and minimal amount of fat.
Hence, density of components of human feces generally exceeds that of water and it sinks in water.
What makes stools to float ??
Gas bubbles trapped in the stool reduce its density, allowing it to float.
If the digestive system is not absorbing fat property, the stool may contain more fat making it buoyant.
Occasional floating stools are often harmless as it results from higher gas content in stool.