They can!
The canine species' gastrointestinal tract is designed to prevent pathogenic bacteria such as salmonella and e.coli from entering and affecting the intestinal tract. A dog’s digestive tract has digestive enzymes that neutralize bacteria and also has a highly acidic stomach that kills any residual bacteria entering the gut.
In other words, dogs in generally good health are not affected by bacterial pathogens and rarely get sick from them. They can however pass on pathogenic bacteria through their stool, so we do advise to wash your hands frequently when handling feces or raw foods.