This may be myopic or off-base, but I feel like JFK had two big advantages with the space program that helped make it happen:
1. His constituents were terrified of the Soviet space program dropping something nasty on their heads, and didn't want to be behind the curve in that arena. 2. His assassination effectively canonized the program. (I think he'd argue my terming that an "advantage.") Cutting it after his death would have been political suicide. Where space exploration often has the same inherent challenge as nuclear power–specifically that the length of any serious endeavor will span several presidents, congresses, senates, to say nothing of economic cycles, (see CxP)–the Apollo program, despite being 2.2% of all federal outlays, had broad support.
There were numerous other factors, but I think those two played a big part in its success.