This is not a legal opinion, just based on having worked in the military police. I don’t ever recall anyone actually being court marshalled for desertion, this was peace time though (86-87).
The way it seemed to work was this. People who just up and left were usually declared Absent Without Leave (AWOL), or Unauthorized Absence (UA) by their unit, don’t know the difference between the two, I was just a grunt.
When they were caught and brought in, but before they talked to any lawyer, they were interviewed, in said interview they would declare whether they left “with the intention to return”, or “intending to never return”. As far as I know, every one of them chose the “intending to return” option, no fools they. As it turns out the charge of “desertion” hinges on intent, if they left “intending to never return”, that was desertion, otherwise it was UA.
These people usually stayed in the brig for a few days, but since they intended to return all along, they were put in a detention house, which is where I worked. Here they were put in regular details, with pay, but restricted to base, until their court marshall.
Thinking back I sort of remember the penalties being kind of all over the field. I think the maximum penalty for UA was 6 months detention (in the brig), bust in grade, and forfeit of salary. Some got 3 months, some got 6, some got time served. But I don’t recall anyone ever being allowed back in the military. Some got Bad Conduct discharges, some got Dishonorable, some got Admin discharges, (DH-bad, BCD-sor of bad, AD-not bad at all). I think it depended on their time in service, why they said they left, how long they stayed, how good a lawyer they got, and in what kind of mood the judge was.
Slightly different topic. In this base there was a huge sweep to catch people with drugs, many were busted. And nearly all of them got 2 years at trial. Except this one guy whose trial happened to take place on a day when the regular military judge was out and a civlian military-reserve judge was brought in. This judge apologized to the kid (these guys were all 18-19), for having to sentence him so harshly but this was the military blah, blah, blah, and gave him 6 months detention. The kid was almost literally walking on air on the way to the brig.