There is still much debate about why the Soviet Union – which was consistently way ahead in the early days of space exploration, failed to beat the USA to putting a man on the Moon. But while there is some disagreement over which factors were the most important, there is considerable consensus about which factors drove this.
They started later.
The USA made putting a man on the Moon the key national objective, from before they had even put a man in orbit. Pretty much the entire space program focused on this objective. By the time this became a national objective in the Soviet Union, 2 years later, time was very tight to develop a powerful enough rocket, and get the required expertise in flight systems.