This happened more in American history, especially during the civil war. Why was ther a regiment of Jews or a separate regiment for African Americans.
This is a little vague. The text of the question implies that you primarily mean the American army of the Civil War (or, presumably, the Union and Confederate armies), but it isn't clear whether you mean other militaries too, for which there are rather a few reasons corresponding to the multiple periods, cultures and socio-political situations. Do you have one military in mind, or many?