By that sort of logic the Union could have, and by rebel standards should have, hanged every Confederate soldier they captured for treason.
They couldn't even Hang Jeff Davis for Treason. I think that if they had attempted hanging Confederate soldiers for Treason, it would have backfired very badly in their own states.
The Soldiers which you clearly did not mention were traitors, were in fact as demonstrably traitorous as it is possible to be. They first fought for their own homeland, and then they joined the enemy forces to fight against their homeland.