Not that they surrendered, but that they had no more options, sooner or later they were going to capitulate, they were economically asphyxiated. Dropping nuclear bombs on them was totally disproportionate.
The first bomb I can't tell you but the second bomb was 100% for experimental purposes since the first one on Hiroshima was enriched uranium and the one on Nagasaki was plutonium. In the second bomb, the plutonium one, they simply wanted to prove that it worked and it was much cheaper than the uranium one.