[deleted]
Re: the USSR, I am not sure what kind of imaginative counter-factual that would require (e.g., Stalin starts working on a bomb in 1939?), but the amount of the Soviet manpower and economy that was required for fighting the Germans in World War II pretty much ruled it out. It took them years to scout out the uranium reserves necessary to build the bomb as it was. There was absolutely no effort to try to build an atomic bomb during World War II by the Soviets for these reasons — they just didn't have the resources to do it in that short of a time-scale, and they had so many other things on their plate.
The German case is of course the more interesting one, because we know that they were interested in nuclear weaponry, but didn't really have a weapons-production program. They decided, in 1942, to limit their main investigations to reactor technology, and even that was a relatively modest endeavor. The Manhattan Project of the Allies is not the "gold standard" of how to make a nuclear bomb but it may be a good benchmark for what it takes to built one in the span of two or three years.
Could the Germans have built a bomb in the same timescale, if they had pledged their resources there and not, say, towards the V programs? I doubt it, personally. Aside from the fact that their resources, labor, and brainpower were already very stressed by the war, they were also under heavy aerial bombardment during much of this period. This would have added difficulties well above-and-beyond those faced by the Manhattan Project, who did not have to deal with any serious work disruptions, and could build massive (largest in the world, in fact) factories with impunity. Germany just didn't have those options — their big factory sites were bombed regularly, their labor supply was heavily taxed by the war (and while you can do some of that work with concentration camp labor, you can't do all of it with that), and they had suffered heavy brain-drain as a result of their anti-Semitic policies. The latter might not have been crippling if they had more time, but it took a ridiculous amount of top-notch brainpower for the Americans to pull it off in that amount of time, and the Germans would have a much harder time with that.
The only ways you can imagine the Germans doing it is if 1) they really went at it with everything they had, and didn't misdirect their budgets elsewhere; 2) they got phenomenally lucky in not going down any blind-alleys; 3) they managed to somehow insulate the entire program from bombing/sabotage by the Allies (who were deliberately looking for anything that might look like an atomic research program and attacking it — not just the famous Norsk hydro raid, but other bombing raids as well). It's a lot to have line up well, with very little wiggle room. Even the Manhattan Project, with all of its advantages and resources and brainpower, barely managed to have an atomic bomb ready for the Pacific Theatre. As it was, the Germans didn't pursue it with much vigor — their research program was orders of magnitude smaller than the Manhattan Project. Anyone who wants to believe the Germans could have pulled it off generally have to posit some kind of German exceptionalism that I just don't think there is any evidence for.