May a Muslim refuse military service on grounds of conscience?
Whether a war is just is something the ordinary citizen usually cannot judge, and a soldier is not held answerable before God for a wrong decision by his government. But an order to kill innocent people such as children or women he must refuse.
In war an ordinary citizen cannot know and weigh all the circumstances. That decision is made by those who are responsible for the country. They may be right, and they may be wrong. But at such times a society has to hold together, and that requires discipline. The first verse above asks for obedience to those who are in authority.
If a government takes a wrong decision and the war is not justified, the soldier who takes part in it is not called to account by God for that. That burden lies with those who decided on the war. To refuse service only because one personally thinks the war is wrong is therefore not the way Islam teaches.
It is different with particular orders that are plainly wrong. Everyone knows it is forbidden to shed innocent blood, such as that of children and women when a city is taken. All religions teach this. The second verse above shows how grave such a deed is before God. If a superior orders such a thing, the soldier must stand firm and refuse. The hadith above says exactly this: when disobedience to God is commanded, there is no obedience.
The world sees it this way too. After wars, war crimes are investigated, and those who killed innocent people are held to account, even if they acted on orders. The soldier is not responsible for the great decision about the war. But for his own hand he always remains responsible.