The British Empire executed approximately 346 Commonwealth soldiers during WWI. These individuals were convicted of either desertion, cowardice in the face of the enemy (refusing an order to attack), striking an officer, or sleeping on guard duty. Not one Australian soldier was convicted of these crimes, but 23 Canadians were, as were four Irishmen. I tried to find some WWII data for the Brits, but all I found was that only one Canadian, Pvt Harold Pringle, was executed for desertion during the Italian Campaign. Some Indian Army troops were also executed for desertion, and this this crime was compounded by joining the Japanese forces as turncoats.
Germany only executed a total of 48 troops for various crimes during WWI. The historical record is much more murky for WWII. When both the Eastern and Western Fronts began to collapse in the summer of 1944, desertion became a problem. The during last six months of the war significant numbers of German troops and Volksturm personnel were summarily executed for a variety of offenses to include desertion, abandoning one's post, allowing military equipment to fall into enemy hands, etc, etc.... The last few months of the war teams of SS troops patrolled the rear areas looking for deserters, whom were often hanged from street poles as an example.
There doesn't seem to be any hard data on desertions in the Czarist Army of WWII. I did read that four million soldiers deserted from the Red Army during the Civil War of 1918-1922, but I take those numbers with a grain of salt. It seems to me that this number would be more appropriate for the Whites, who suffered mass defections. The number of Soviets convicted of desertion and similar crimes during WWII is approximately one million. About 422,000 soldiers were sentenced to the penal battalions. They received a certain number of months service in the penal units, and if they survived they were returned to a regular unit. The condemned Soviets that were not sent to the penal battalions were either liquidated or sent to slave labor camps for long sentences. Large numbers of Red Army soldiers who became POWs and were later liberated fell into this category. On 28 July 1942 Stalin ordered that any troops or units that retreated without permission were to be shot on the spot. The NKVD troops performed this function, as well as ferreting out deserters and "defeatists".
WWI Italy had so many draft dodgers and deserters that it became a national scandal. The total number of deserters and draft dodgers were estimated to number at least 450,000, which equals the number of war dead Italy suffered in WWI. Two factors caused this; the war did not have popular support and a number of large Italian cities were close to the battlefront. During the disastrous Battle of Caporetto, very large numbers of Italians fled the battle. The Carabinieri (the Italian national police that become MPs during wartime) shot large numbers of deserters and stragglers to get control of the situation. Officially, only 500 Italian troops were executed for desertion or cowardice, but that figure is probably considerably higher. Desertion became a problem in WWII only when the war came to Sicily and southern Italy. Desertion wasn't much of a factor in North Africa, East Africa, Greece/Albania, or the USSR......the chances of getting home by deserting were not good on those fronts.
Officially, WWI France executed 600 soldiers for desertion or cowardice, but these figures are artifically low. If a French unit broke under enemy fire it could suffer "decimation" in which every tenth man in the unit formation was summarily shot (the Soviets also did this early in the Battle of Stalingrad). There was a widespread mutiny in the French Army in 1917 after the disastrous Chemin les Dames offensive. Many troops that mutinied were shot. There was a Polish volunteer battalion that refused to fight and the loyal French units stationed nearby exterminated them. The French Army of WWII faced the problem of desertion with apathy (the French Army faced all of it's challenges with apathy in 1939-40). As a result, there was an epidemic of desertion and other morale/discipline problems during the "phony war" of Sept 1939 - April 1940. In fact, British troops stationed in France in 1939 - 40 nicknamed desertion "French leave". During the Battle of France an unknown number of French soldiers were shot for desertion, cowardice, and looting.