The exact same reasons that most US planes stuck to .50 Cals instead of cannons.
Reliable. The M2 (and later M3) were already in production from before the war, were tried, true, and proven designs, relatively cheap, packed a good punch, and were pretty easy to maintain.
The next best competitor was the American copy of the Hispano/Suiza 20mm, the AN-M3 suffered from quite a few reliability issues in various platforms that were never quite solved until fairly late in the war.
They were pretty small. Like don't get me wrong the M2 is a big fuckin gun but compared to cannons of other sizes, you can fit a good number of them into a pretty small area. And since their ammo is smaller you can fit more of it in the plane. This point is REALLY important in bomber missions for lasting out a battle since space is obviously very cramped and loading 20mm ammo in a tiny turret isn't exactly the easiest.
And then because the .50s were already in service on basically EVERY American plane, it made interchangeability super easy. With a bit of rigging the .50s from a scrapped P-47 or P-51 could be thrown into a B-17 and vice versa. The US loved having shared parts cause it made maintenance significantly easier.
And as a side note, most American aircraft only ever engaged other aircraft. Rarely did the US ever engage bombers and no heavy bombers on par of the B-17, B-24, or B-29 ever saw service with the Axis powers. Obviously the Germans and Japanese needed more firepower to shoot down those behemoths, hence why 190's, 109's, and J2M's could have anywhere from 2-6 cannons.
EDIT: I can't speak for why the Germans had such diverse weaponry across the board
I should probably have better explained that I'm asking about German bomber armament with the mention of Americans being a comparison.