We should also remember how new the high velocity 12mm - 20mm technology was in the lead up to WW2. The Becker Type M2 20mm gun only went into production in 1916, and in many ways was a weapon looking for a purpose. The light construction of most WW1 aircraft really only needed rifle calibre rounds to bring down. The 12mm - 13mm rounds being developed were mainly for anti-tank use, once again, not in service until 1916.
So, effectively, in a space of 20 years a wide range of guns and ammunition was developed that previously not been used, and in many ways did not have a target (for naval purposes 45mm was really the minimum calibre for anti-torpedo boat work, and if two ships had come in machine gun range of each other then something either very serious or strange had occurred.
Having said that the requirement for aircraft to even strafe ships was probably invented by Billy Mitchell as part of the June - July 1921 tests.
Going on just 20 years, the Douglas Dauntless had two .50cal forward, whilst the later Helldiver went to 20mm. The Skyraider also had 20mm, which would tend to indicate that the USN, the most experienced navy in attacking ships, had decided that 20mm was better than .5cal. Of course the Grumman Avenger had .50cal.