Japan was in no way "totally surrendered"..the country was worn down, but the Banzai spirit very much lived on and the ersatz-samurai militarists were fully prepared to continue waging a war of attrition that would see the civil population sacrificed to inflict even marginal losses on the allied invaders.
Incidentally, none different from the Nazis and their "Volkssturm" battalions of children and infirm elderly.
The nuclear bombs over Hiroshima and Nagasaki gave the Emperor and more moderate leadership of Imperial Japan a plausible and honorable way to bow out without having their population eradicated in what would be a protracted and pointless extension of the war.