One of the popular Internet lecturers who is a strong Zionist likes to say that all Charedim have to enlist in the army b/c it is a מלחמת מצוה so הבא להרגך השכם להרגו - as if the obligation to fight in a מלחמת מצוה stems from the rule of השכם להרגו.
He is confusing two completely separate issues. One issue is מלחמת מצוה. A completely separate issue is הבא להרגך השכם להרגו. The former is a Halacha that relates to the community as a whole. The latter relates to an individual.
If there is such a concept as מלחמת מצוה in our days is questionable given that one needs a מלך [apparently - see רמב"ם הלכות מלכים ומלחמותיהם ה-א] in order to wage such a war. We don't have a מלך. That is a big question which is beyond the scope of this post. Thankfully, there is *someone* who has dozens and dozens of very very in depth shiurim on the Rambam Hilchos Melachim Umilchamoseihem which you can listen to. Most people are ignorant about the intricacies of these Halachos which sadly doesn't stop them from expressing opinions about it. Like Corona. So many opinions - so little knowledge.
הבא להרגך השכם להרגו means that if someone is attacking you - kill him first. The average citizen is not being attacked so that would not apply. In all of the literature about the mitzva to wage wars, we don't see the poskim invoking the rule of השכם להרגו [or if they do it is rare]. [It is not clear that השכם להרגו is a mitzva as much as it is a רשות. The right to self defense].
There IS an issue of לא תעמוד על דם רעך which requires one to protect the lives of other Jews which would apply here. That is certainly a mitzva and a big one at that.
This same lecturer also brought a definitive proof [in his biased mind] that Yeshiva students must serve b/c a מלאך was critical of Yehoshua for not learning during a break from battle [מגילה ג]. How does that prove that Yeshiva boys must leave Yeshiva and go to the army? Of course it doesn't.
The Rambam at the end of שמיטה ויובל which is marshalled as a proof that Yeshiva boys need not serve in the army is also not a proof. If the Rambam held that way - why doesn't he tell us in the place where it belongs - הלכות מלכים? He also ends sections with Agada and not Halacha which is what he did here. [And for other reasons as well it is not a proof].
So should Yeshiva boys all leave Yeshiva and go serve?
As I have written in the past - this is a question for Gedolei Olam and not for anyone who can click on a source sheet from Sefaria. The difficulty is not in accessing sources but in properly understanding them and applying them to our reality. וד"ל.