I think the main answer to this question is "it depends on campaign and DM". Back in the 3rd edition you had Blood War as others pointed out, and the general rule was that Devil and Demons were completely different beings that did not cooperate. That they were natural enemies, and even though both were evil, the nature of evil their represented was so radically different that they were natural enemies.
In other editions, from 1st till 5th it kinda depended on world.
Personally I think that Devils and Demons are completely different type of an Evil. Think of a Devil as an evil politician that commits great evil, such as starting genocide, but follows certain rules and regulations to the letter of the law. While Demon would be something like a spree killer, kills for the pure pleasure of it.
Given that it is difficult for them to cooperate, but not impossible . The thing is that both Devils and Demons are in fact very smart beings. They don't just react they think, they plan, they make friends and enemies. While their thought process maybe completely different, they still might use one another to achieve their own gain. For instance in order to take over this city full of souls, a Pit Fiend may cooperate with Balor. However they are likely to fight each other after words.
Now personally in my campaign I take things on individual level, and so unless a being is of pure magic, they have an option. Therefore you could have non-evil Red Dragon, or a good Devil, given right circumstances. Just that such things are very rare, especially given that Hell/Abyss is itself an evil place, always corrupting everything that is within its reach. So being a good devil is not only against its very own nature, it also would need to fight of other Devils (who would see that as heresy) but also the world itself that keep trying to corrupt you. Yet it can and did happen.
So my answer is, do in your world what you think is right, and tells best story you can.