The active ingredient in Pepto Bismol is a compound called bismuth subsalicylate. This compound has anti-diarrheal, anti-bacterial, and antacid effect on the digestive tract. This is why Pepto helps with stomach discomfort.
The thing is, when the bismuth combines with the trace amounts of sulfur in your saliva and in your gastrointestinal tract, it reacts to form a black substance called bismuth sulfide.
Bismuth sulfide is where the discoloration on your tongue comes from. And bismuth sulfide can also temporarily darken the stool. It’s a common enough side-effect that it’s listed in the package information, which you really should get in the habit of reading.