Hinduism is big on non-violence (ahimsā) but there are times it’s justified, usually to restore dharma, righteousness. The Kurukshetra War in the Mahābhārata is one such example. A prince of one branch of the royal family (Duryodhana was his name) usurped the throne from another prince of another branch, Yuddhishthira was his name. They were first cousins. This prince was the rightful heir. But by a technicality of succession Duryodhana refuted this and usurped the throne.
After several unsuccessful attempts were made to settle it peacefully, with Krishna being the main arbiter, war was inevitable. Members of the usurper’s branch of the family tried to convince him he was wrong, to no avail. No one on either side wanted war, except Duryodhana. He had issues. Arjuna, Yuddhishthira’s younger brother was a skilled archer, probably the best. On the battlefield he saw that on the opposing side were his cousins, uncles, teachers, and in particular one favorite uncle on who’s lap he played as a child.
Arjuna put down his bow, sat down all verklempt and said to Krishna (Krishna was Arjuna’s charioteer but said he would not raise a weapon) he would not, could not kill his beloved cousins, uncles, teachers, including a half brother he only recently found out about, etc. Krishna told Arjuna that because he was Kshatriya, born into the warrior class, it was his job, his duty to fight for justice, regardless of whom he was fighting. This conversation is the Bhagavad Gita.
So, while Hinduism is very much anti-violence it recognizes the need to use violence and force when dharma is threatened. People have used this justify vigilantism, saying they’re working for the common good but that’s incorrect. The Kshatriya, ancient or modern soldiers, police, all law enforcement officials, do not go on the offensive. That is not justified. When Lord Rāma went to Lanka to free Goddess Sītā from Rāvana, Rāma gave Rāvana every chance to release Sītā and stop his reign of terror. Rāvana was so bad and powerful, Goddess Earth pleaded with Lord Vishnu to be born and stop Rāvana’s evil. Only when he wouldn’t did Rāma wage war.
So, war is very much justified in Hinduism.