How many Union generals deserted to the Confederate side in the midst of combat operations while bearing valuable intelligence information and demanded commissions in the Confederate army?
Lee, Jackson, et al did so. You do not seem to understand that an officer may resign a commission only with the approval of the Commander-in-Chief, and even then is obligated and subject to recall to active duty the remainder of the officer’s life, once the person has accepted the commission.
In other words, Robert E. Lee could have resigned his commission with the approval of President Lincoln and the Secretary of War, honorably sat out the war as a civilian; but he was subject to the orders of his Commander-in-Chief, President Lincoln, and subject to the oath of Loyalty to the United States of America for the rest of his life. Taking up arms against the government to whom he swore his oath of loyalty for life was an act of insurrection and treason no matter how you try to pretty it up.
Oaths have consequences, and should not be taken lightly, foolishly, or dishonestly.