Desertion
Desertion versus absence without leave: In the United States Army, United States Air Force, British Armed Forces, Australian Defence Force, New Zealand Defence Force, Singapore Armed Forces and Canadian Armed Forces, military personnel will become AWOL if absent from their post without a valid pass, liberty or leave. The United States Marine Corps, United States Navy, and United States Coast Guard generally refer to this as unauthorized absence. Personnel are dropped from their unit rolls after thirty days and then listed as deserters; however, as a matter of U.S. military law, desertion is not measured by time away from the unit, but rather:

by leaving or remaining absent from their unit, organization, or place of duty, where there has been a determined intent to not return;
if that intent is determined to be to avoid hazardous duty or shirk contractual obligation;
if they enlist or accept an appointment in the same or another branch of service without disclosing the fact that they have not been properly separated from current service.
People who are away for more than thirty days but return voluntarily or indicate a credible intent to return may still be considered AWOL. Those who are away for fewer than thirty days but can credibly be shown to have no intent to return (for example, by joining the armed forces of another country) may nevertheless be tried for desertion. On rare occasions, they may be tried for treason if enough evidence is found.
There are similar concepts to desertion. Missing movement occurs when a member of the armed forces fails to arrive at the appointed time and place to deploy (or "move out") with their assigned unit, ship, or aircraft. In the United States Armed Forces, this is a violation of the Article 87 of the Uniform Code of Military Justice (UCMJ). The offense is similar to absence without leave but may draw more severe punishment.
Failure to repair consists of missing a formation or failing to appear at an assigned place and time when so ordered. It is a lesser offense within Article 86 of the UCMJ.
An additional duty status code — absent-unknown, or AUN — was established by the U.S. military in 2020 to prompt unit actions and police investigations during the first 48 hours that a service member is missing.

By country: 

Australia: During the First World War, the Australian Government refused to allow members of the First Australian Imperial Force (AIF) to be executed for desertion, despite pressure from the British Government and military to do so. The AIF had the highest rate of soldiers going absent without leave of any of the national contingents in the British Expeditionary Force, and the proportion of soldiers who deserted was also higher than that of other forces on the Western Front in France.

Austria: In 2011, Vienna decided to honour Austrian Wehrmacht deserters. On 24 October 2014, a Memorial for the Victims of Nazi Military Justice was inaugurated on Vienna's Ballhausplatz by Austria's President Heinz Fischer. The monument was created by German artist Olaf Nicolai and is located opposite the President's office and the Austrian Chancellery. The inscription on top of the three step sculpture features a poem by Scottish poet Ian Hamilton Finlay (1924–2006) with just two words: all alone.

Colombia: In Colombia, the Revolutionary Armed Forces of Colombia (Spanish: FARC) insurgency were highly affected by desertion during the armed conflict with the Military Forces of Colombia. The Colombian Ministry of Defense reported 19,504 deserters from the FARC between August 2002 and their collective demobilization in 2017, despite potentially severe punishment, including execution, for attempted desertion in the FARC. Organizational decline contributed to FARC's high desertion rate which peaked in the year 2008. A later stalemate between the FARC and government forces gave rise to the Colombian peace process.

France: Many individuals who were conscripted by the French First Republic during the French Revolutionary Wars deserted. There were rough estimates to the number of individuals that deserted during the time of the Levée en masse, but due to many factors, like the inability to manage and keep track of all the armies or differentiating between men with similar names, the exact number is unclear. In 1800, the Minister of War (Carnot) reported that there were 175,000 deserters based on the number of individuals that sought the benefits following the amnesty put in place. 
From 1914 to 1918 between 600 and 650 French soldiers were executed for desertion. In 2013, a report for the French Ministry of Veteran Affairs recommended that they be pardoned.
Conversely, France considered as highly praiseworthy the act of citizens of Alsace-Lorraine who during WWI deserted from the German army. After the war it was decided to award all such deserters the Escapees' Medal (French: Médaille des Évadés).

Germany: During the First World War, only 18 Germans who deserted were executed. However, the Germans executed 15,000 men who deserted from the Wehrmacht during the Second World War.  In June 1988 the Initiative for the Creation of a Memorial to Deserters who deserted the Wehrmacht came to life in Ulm.

Ireland: Ireland was neutral during the Second World War; the Irish Army expanded to 40,000 men, but they had little to do once it became clear in 1942 that invasion (either by Nazi Germany or by the British Empire) was unlikely. Soldiers were put to work cutting trees and peat; morale was low and pay was bad. Of the 60,000 men who passed through the army in 1940–45, about 7,000 men deserted, about half of them deciding to fight on the Allied side, most joining the British Army.
Once the war was over, the EPO 362 order meant deserters were allowed to return to Ireland; they were not imprisoned, but lost rights to an army pension and could not work for the state or claim unemployment benefits for 7 years. They were also seen as traitors by some Irish people in their homes.
Decades after, the morality of their actions was debated; on the one hand, they had illegally abandoned their country's armed forces at a time when it was threatened with invasion — indeed, it was argued that their acts were treasonous at a time when Britain may have been planning to seize control of Ireland's ports (see Plan W); on the other hand, they chose to leave a safe if tedious posting in order to risk their lives fighting against fascism, and many were motivated by genuine idealism.
In 2012, the Minister for Justice and Equality Alan Shatter issued a pardon and amnesty to all World War II-era deserters from the Irish Defence Forces.

New Zealand: During the First World War 28 New Zealand soldiers were sentenced to death for desertion; of these, five were executed. These soldiers  were posthumously pardoned in 2000 through the Pardon for Soldiers of the Great War Act. Those who deserted before reaching the front were imprisoned in what were claimed to be harsh conditions.

Russia: During the 2022 Russian mobilization, the Putin-controlled State Duma of Russia adopted amendments to include the concepts of mobilization, martial law and wartime in the Criminal Code, and introduced several articles related to military operations. Desertion during a period of mobilization or wartime will be punished by up to 10 years in jail. In December 2022, Kazakhstan deported back to Russia a Russian officer who was trying to avoid the Russo-Ukrainian war.

Soviet Union: 

Russian Civil War: In 1919, 616 "hardcore" deserters of the total 837,000 draft dodgers and deserters were executed following People's Commissar Leon Trotsky's draconian measures. According to Figes, "a majority of deserters (most registered as "weak-willed") were handed back to the military authorities, and formed into units for transfer to one of the rear armies or directly to the front". Even those registered as "malicious" deserters were returned to the ranks when the demand for reinforcements became desperate". Forges also noted that the Red Army instituted amnesty weeks to prohibit punitive measures against desertion which encouraged  the voluntary return of 98,000-132,000 deserters to the army.

World War II: Order No. 270, dated 16 August 1941, was issued by Joseph Stalin. The order required superiors to shoot deserters on the spot. Their family members were subjected to arrest. Order No. 227, dated 28 July 1942, directed that each Army must create "blocking detachments" (barrier troops) which would shoot "cowards" and fleeing panicked troops at the rear. Over the course of the war, the Soviets executed 158,000 troops for desertion.

Soviet–Afghan War: Many Soviet soldier deserters of the Soviet–Afghan War  explain their reasons for desertion as political and in response to internal disorganization and disillusionment regarding their position in the war. Analyses of desertion rates argue that motivations were far less ideological than individual accounts claim. Desertion rates increased prior to announcements of upcoming operations, and were highest during the summer and winter. Seasonal desertions were probably a response to the harsh weather conditions of the winter and immense field work required in the summer. A significant jump in desertion in 1989 when the Soviets withdrew from Afghanistan may suggest a higher concern regarding returning home, rather than an overall opposition towards the war itself.