We can’t speak for all fishes, but it does seem like some species do in fact flatulate a little bit more than it seems they would need for healthy digestion. Large schools of herring in particular have been known to make noises that scientists call ‘Fast Repetitive Ticks Sounds’ or FRTS for short.
There doesn’t seem to be any correlation between the FRTS and any kind of predator danger, and the FRTS are not produced when the herring are sexually active either, which would be weird. Instead, since herring are known to gather in huge schools, it is believed that the FRTS serve as some kind of contact call, to help keep the school together, and the fish at optimal distance for the herring to feed.
But why do the herring using farting for audible communication instead of some other sound? As it turns out, the FRTS are a high frequency sound wave and above the level of hearing that large fish can detect, so there’s no risk of alerting predators to the location of the school due to the farting sounds, which would be a bad move indeed.