Really, it was more of a "The Nazis are doing this. We need to get this done before the Nazis so we can prevent the Nazis using it because we will retaliate." The fact that the war in Europe was over before either side had actually finished the bomb made that part irrelevant.
Unfortunately for science, once discoveries are made and turned over to the military, scientsts' morality gets shoved into a corner.
It's just the WW2 version of "You were so preoccupied on whether or not you could, you didn't stop to think if you should"
Now there's lots of debate on if nukes resulted in the unsteady peace we benefit from today, but fact of the matter is two cities that existed, stopped, existing.
Edit: I'm being a bit hyperbolic but the point still stands.
It's not like the Japanese didn't do horrific shit where they invaded. They killed millions of Chinese innocents and were brutal to POWs. They were a serious imperial evil in their own right.
They were also somewhat responsible for the US believing that they would fight to the last man. They purposely populated the islands in the Pacific with loyalist citizens to make taking the islands difficult. Combined with tactics like the kamikaze attacks, they wanted the US to believe they would never surrender, even if they probably would have.
That said, the main use for the bomb was probably always going to be against large civilian cities. Oppenheimer would have known this, and simply must have believed that the chance of letting the Nazis get it first was too great a threat. He probably figured that if someone was going to build it anyways, at least he could try and influence how it was used. That didn't work out so well, but it might have been better than there not being moderating voices at the table.