Because many of the top European physicists were Jewish or of Jewish heritage, Germany lost Einstein, Bohr, Szilard, Teller, Fermi, among many others. Heisenberg was the only really top-notch scientist left, and as others have mentioned, it’s not clear that he was working wholeheartedly to make a bomb. The only other scientists of note working for the Germans were Otto Hahn, Carl von Wiesacker, and Max von Laue.
The Germans devoted nowhere near the resources to their atomic program that the Americans did. Hitler considered physics “Jewish science” and had no real comprehension of the potential of the Bomb. He was far more interested in his Vengeance weapons (the V-1 and V-2 rocket bombs) and jet planes.
In any case, it is highly unlikely that Germany could have dedicated as much money as was spent on the Manhattan Project (about $2 billion, back when a billion dollars was worth something) without completely gutting the rest of its war effort. And even if they miraculously had spent that much, it’s unlikely they would have had the industrial capacity to make a working bomb. The build-up of Manhattan project has been compared to building the entire U.S. automobile industry in about two years.
That the Manhattan Project managed to build, before the end of the war, two atomic bombs, based on entirely different physical principles (Little Boy, the gun-type uranium bomb, and Fat Man, the implosion-type plutonium bomb) was due to an unbelievable assemblage of genius, hard work, risky decisions, and incredible good luck. Many American physicists didn’t believe it wouldn’t be possible to make a workable bomb in time to be used in the war, and there is no doubt the Germans felt the same way.
Heisenberg built an atomic pile in Haigerloch, near the Black Forest, for neutron multiplication studies. But it was much too small to sustain a chain reaction, something Fermi had accomplished in Chicago on Dec. 2, 1942.
There is a telling incident regarding how far behind the U.S. the Germans were. Heisenberg and the other German physicists were captured by the Allies in the spring of 1945 and held prisoner in a farmhouse in England. The place was bugged in an attempt to determine the answer to the question in the OP. When the Germans heard that the Americans had dropped and atomic bomb on Japan, Heisenberg flatly refused to believe that it was a uranium bomb or had anything to do with fission. He was certain they were lying, or that the device had been misreported.
For additional information, I recommend Richard Rhodes’ The Making of the Atomic Bomb, Gen. Leslie Groves’ Now It Can Be Told, Samuel Goudsmit’s Alsos, and Stephane Groueff’s The Manhattan Project. All but the first are out of print, but you could find them in a good library or at an online used bookseller.