Using quickly googled sources for wartime prices:
Cost of a single Brewster F2A without weapons and instruments as sold to Finland: $54000 (admitted, this WAS way overpriced, but hey, situation being what it was)
Cost of a single 40mm Bofors: $9500
Cost of a single FlaK 38: $2400
Also, guns are easier to manufacture yourself than planes, plus there was a smaller risk of losing a gun tube than a plane, because SEAD was not a thing yet.