It is a great commandment from the Torah to save a person in danger. When it comes to saving all of Israel, it is considered a clear obligatory war. The commandment to study Torah does not override the commandment to enlist in the army but the discussion about the government’s survival is a different matter and coercive conscription is not feasible