If medications are absorbed through the bowels, why aren't bacteria absorbed also?

Meds are smaller. Molecules of medication are far smaller than bacteria. Note, however, that bacteria can cross the bowel into the blood when there is damage or inflammation as can happen with bowel ischemia for example.
Body's defenses. A couple of reasons for bacteria not being "absorbed": 1) the intestinal lining (aka epithelium) has cells that are connected throguh tight junctions that does not allow bacteria through. Medications are typically much smaller than bacterial, and can pass through this epithelial lining. 2) mucosal defenses results in vacvteria getting mired in the mucosal layer lining the GI tract.
Normally not. Medications specially made particles easily absorbed thro gut, to blood stream for the maximum benefit to the body. Most of the bacteria have a coating that prevents them from getting absorbed. Most of them are commensals, meaning they help us digestive system. When an overwhelming infection occurs, disease causing bacteria can pass thro the channels in the gut.
Different sizes. Medications are broken down into very small pieces by enzymes and even the bacteria in the intestine so they're small enough to be absorbed. Bacteria are too big to be absorbed, although sometimes bacterial products can be. In some disease states bacteria can get too deep in the lining of the gut and cause severe illness.