Cannon
The difference, in small arms, is cannon can fire explosive shells, rifles and machineguns cannot. In artillery it is different. Since artillery normally fires explosive shells, technically they are all cannon. So artillery pieces are named after their prinicple purpose. And the term cannon is sometimes used, but sometimes they are just called "gun" Tank cannon are usually called "guns". There are (or used to be) anti-aircraft guns. Howitzers are a certain class of "gun" Naval cannons are called "guns", or "rifles".
Mortars and grenade launchers seem to be in their own category, as they are never called guns
or cannon.
20mm is the smallest cannon used by our military during the last century or so. Other countries weapons are usually described in our terms.
Aircraft guns during WWII run from rifle caliber (.30, .303, 7.7mm, 8mm, etc) up to heavy machinegun (.50cal, 13mm, etc) and then to 20mm cannon. 30mm, 37mm, 50mm, and even 75mm guns were mounted in or on aircraft by different countries during the war.
Most German fighters mounted 20mm and later 30mm cannon. There were also tank buster Stukas that carried a pair of 37mm cannon, and a few late war "bomber-destroyers" that carried a cannon as large as 50mm.
US fighters mostly used machineguns, but there were a couple that carried a cannon as well. The P-38 carried a 20mm cannon, along with .50 cal machineguns. The P-39 had either a 20mm or a 37mm cannon
, along with .30 and .50 cal machineguns. But most of our fighters carried either 4, 6, or 8 .50cal Browning machineguns.
One version of the B-25 bomber carried as many as 12 .50 cals in the nose, AND a 75mm howitzer!
While there were some cannon which outranged our .50BMG, there were many that did not. They fired at a lower velocity than the .50BMG, and so, while the shells were more destructive, they had more drop, and so, less useable range.