The guns weren’t useless at all,their primary purpose was to make it difficult for attack aircraft to approach easily and “Get their shot”.
Without defensive armament attacking fighters could have ambled up from any direction ,attitude and altitude and attacked the bombers at their leisure.
Also in the early days,heat seeking missiles went for the aeroplanes exhausts(When they worked at all)which meant that they went for the target from the rear,so rear mounted guns had the best chance of taking out the missile.
In this particular discussion, that is not exactly true. When LeMay brought Bomber Harris’s tactics to the Pacific, he started sending B-29s out as night mission fire bombers–then stripped out much of the defensive armament to give them greater range and speed, based on the (mostly correct) notion that the Japanese had no really effective night fighter squadrons.