Passing gas is a normal part of the digestion process. However, if gas builds up in the intestines, it can be painful. Trapped gas has several different causes and various treatment options. A person may experience sharp pain or discomfort in their abdomen if gas does not move through their intestines normally. Gas is usually the result of bacteria digesting food in the large intestine or the person swallowing air when eating or drinking. It is normal for people to pass gas roughly 13–21 times a day1.
As for your question about passing stool without expelling gas (farts) through the anus, it is not possible. The stool moves through the intestines by peristalsis, which is a series of muscle contractions that push the stool along. As stool moves through the intestines, it pushes gas ahead of it. This means that it is inevitable to fart even if hypothetically (or experimentally) there were no bacteria present in the gut1.
I hope this helps!