I'm unsure how people defending themselves in their own country (to be clear, in this case, it's Afghanistan) against an attacking force (to be clear, I supported that action) can be illegal combatants.

Because they are not clearly identified as a soldier. Does that make sense? If it were legal for combatants can be dressed in civilian clothes and act like a civilian and then take pot shots at clearly identified enemy combatants then all civilians would then be suspect and the civilians who wish immunity from being shot at on sight will be much more likely to be shot at on sight because the ennemy combatants can't tell the difference. That's why it is a rule of war.