If someone attacks you or your ally, or attempts to take something of
yours by force, then war is absolutely justified. I think civil war,
specifically a coup, can be justified when the government fails to meet
the needs of it's citizens.
In many cases, war can be prevented by having a "bigger stick" and by
maintaining good relationships. And many countries can avoid civil war
simply by giving citizens basic freedoms while taking measures to ensure
the stability of the economy.