Why did Japan not replace the 25 mm gun with a 40 mm weapon?
Short answerThe industrial conversion was substantial, and by the time the need was obvious Japan no longer had enough time or spare capacity.
NotesJapan examined 40 mm weapons and obtained examples, but a new system required tooling, training, and several months of interrupted production. A deliberate 1940 switch could plausibly mature by the period when air attack became most dangerous; attempting it after the war began was much harder. Factory conversion would temporarily reduce output before the replacement weapon appeared in useful numbers. The missed window shows why recognizing a weapons problem before mobilization can matter more than finding a technically superior design during war.