Why wasn't the United States charged with war crimes for the bombs on Nagasaki and Hiroshima?

An opinion was rendered in international courts to wit:

"in the light of international humanitarian law, it should be borne in mind that during the Second World War there was no agreement, treaty, convention or any other instrument governing the protection of the civilian population or civilian property, as the Conventions then in force dealt only with the protection of the wounded and the sick on the battlefield and in naval warfare, hospital ships, the laws and customs of war and the protection of prisoners of war"

At the time, "total war" meant the civilians on both sides faced indiscriminate aerial bombing, including incendiary attacks, nuclear attacks, and assaults on centers of culture/churches/schools, etc.

A change in the Geneva Conventions, beginning in 1949 were the results from the uproar of the fire bombing of Dresden, nuclear attacks on Japan, and other indiscriminate carpet bombing during WW II.

Therefore, in answer to your question, there were no specific treaties or conventions broken AT THE TIME of the bombings and therefore it was not a war crime, these prohibitions all came after the war.