The smaller guns were for defence against small craft, against whom the main armament could not be easily or economically employed.
For defense against smaller ships, smaller weapons were employed when the main weaponry was impractical or costly to use.