The Levites did not usually serve as Conscripted Soldiers
Sources of Illustration: The Maccabees/Hasmoneans
The Tribe of Levi did not go out to War when it was Optional or when it involved Conquest of the Land.
In Torah Law one has Optional Wars and Commanded Wars.
Optional Wars are those that do not directly entail death or survival. For instance the Israelites might need to conquer areas outside of their border or bring recalcitrant foreigners to heel. These are things that might be necessary to but it would be possible to survive, at least for a while, without them.
Commanded Wars ("Milchamot "Mitsvah") are wars where there is a direct threat to the existence of Israelites or something similar.
Conquering the Land may also be considered a Commanded War. Nevertheless in such a case the Levites were expressly absolved from participating in them. The Levites did not inherit a Tribal Portion of their own but rather settlements or parts of townships scattered throughout the other Tribes.
When the Israelites were numbered in the Wilderness the Levites were not included in the general census. All the other Israelites between the ages of 20 to 60 were.
The Levites were later numbered separately from the age of one month.
Numbers (NKJV) 1:
2 Take a census of all the congregation of the children of Israel, by their families, by their fathers’ houses, according to the number of names, every male individually, 3 from twenty years old and above, all who are able to go to war in Israel. You and Aaron shall number them by their armies....
47 But the Levites were not numbered among them by their fathers’ tribe; 48 for the LORD had spoken to Moses, saying: 49 Only the tribe of Levi you shall not number, nor take a census of them among the children of Israel;
We see here that the Levites were not counted among "all who are able to go to war in Israel."
Numbers (NKJV) 2:
32 These are the ones who were numbered of the children of Israel by their fathers’ houses. All who were numbered according to their armies of the forces were six hundred and three thousand five hundred and fifty. 33 But the Levites were not numbered among the children of Israel, just as the LORD commanded Moses.
The Levites were set ASIDE and later numbered separately from one month old and upwards.
15 Number the children of Levi by their fathers’ houses, by their families; you shall number every male from a month old and above.
Nevertheless, the Levites could defend themselves. They could perform certain police duties. They could serve as guards around the Temple area. In exceptional circumstances they could even go to War when no other choice was available.
After the Israelites transgressed in the Wilderness by worshipping the Golden Calf Moses commanded the Levites to take their swords and put the offenders to death. Thy did so.
Exodus (NKJV) 32:
25 Now when Moses saw that the people were unrestrained (for Aaron had not restrained them, to their shame among their enemies), 26 then Moses stood in the entrance of the camp, and said, 'Whoever is on the LORD's side, come to me!' And all the sons of Levi gathered themselves together to him. 27 And he said to them, 'Thus says the LORD God of Israel: "Let every man put his sword on his side, and go in and out from entrance to entrance throughout the camp, and let every man kill his brother, every man his companion, and every man his neighbor."' 28 So the sons of Levi did according to the word of Moses. And about three thousand men of the people fell that day. 29 Then Moses said, 'Consecrate yourselves today to the LORD, that He may bestow on you a blessing this day, for every man has opposed his son and his brother.'
In similar manner, the Hasmonean Maccabees fought wars against Syrian-Greek oppressors and against fellow Jews who collaborated with the idol-worshipping Gentiles. The Hasmoneans were from a family of Cohens (Priests) from the Tribe of Levi.
The principle is that they who dedicate themselves to serve the Almighty are freed from duties that can normally be done by others.
Exceptions exist but they really need to be exceptional.
Maimonides, Mishneh Torah, Laws of the Shemittah and Jubilee Cycles, 13:
12. Why did Levi not merit to participate together with his brothers in inheriting the Land of Israel and its booty? The Tribe of Levi had been separated to work for God, to serve Him, and to teach the masses His righteous ways, as it says, "They shall teach Jacob Your judgments, And Israel Your law" (Deuteronomy 33: 10). For this reason they have been set aside from the Needs of this World. They do not wage war like the rest Israel does. They do not inherit [in the land] nor do they take for themselves by force [from the enemy]. They rather comprise the Army of the Almighty, as it says, "Bless his substance, LORD" (Deuteronomy 33:11). God, may HE be Blessed, is the One who merits on his behalf, as it says, "I am your portion and your inheritance among the children of Israel" (Numbers 18:20).
13. Not only the Tribe of Levi, but any man of all the inhabitants of the earth, whose spirit has moved him and whose mind has given him to understand to set himself aside to stand before G-d to serve Him, to worship Him, to know G-d and walk justly as G-d has created him, and he cast from his neck the yoke of the many calculations that men seek, this man has become sanctified, a holy of holies, and G-d shall be his portion and his lot forever, and shall grant him his needs in this world, as He has granted the Kohanim and the Levites...
Deuteronomy (NJKV) 33:
They shall put incense before You,
And a whole burnt sacrifice on Your altar.
11 Bless his substance, LORD,
And accept the work of his hands;
Strike the loins of those who rise against him,
And of those who hate him, that they rise not again.