Maybe flies don't like shit. Maybe the are only "forced" to hang around shit because sadistic, evil wasps like to watch flies humiliated.
Or, maybe they are trying to discourage certain things from eating them by giving themselves a defensive "shit odor."
Then again, maybe they only resort to shit when dead, rotten things are scarce.