Both Hiroshima and Nagasaki were legitimate military targets, Hiroshima being the headquarters of the 2nd General Army, under Field Marshal Hata, responsible for the defense of the western area of the Home Islands, home to around 45K military at the time and port of embarkation for forces going to Kyushu. Nagasaki was the principle city on Kyushu, and a military industrial production center, primarily Mitsubishi plants. And the island was the destination of the first landings in the Home Islands, Operation Olympic, scheduled for less than 3 months in the future.
Though legitimate military targets, the destruction of the military assets was not the primary goal of the bombs. That was the will of the hardliners on the Supreme Committee for the Conduct of the War, to continue the war, to a more advantageous negotiated peace. The bombs, through the economy of scale (one plane, one bomb) in producing the severity of damage that was anticipated, targeted the will of the controlling clique in the Japanese military. Successfully, given the Emperor’s reaction to them…