I've given various answers on this topic, a few of which you can read below. The short answer to this question is that the Space Race was an extension of the technology grab that occurred directly after WW2. Once the Americans grabbed von Braun and his team of rocket scientists and engineers, they (Americans) wanted to build working V2 prototypes for intermediate and long range missiles. Not to be outdone, the Soviets took whatever was left, including missile blue prints and mid level engineers to build their own rockets.
Von Braun had his sights on space and thus viewed the US Army missile program as a means to an end. This is why all of the space vehicles during the 1950's and 1960's were all military short range ballistic missiles (as were the Soviet's) converted for "peaceful" use.
[German scientists working for the US] (https://www.reddit.com/r/AskHistorians/comments/1hz8hd/did_the_us_or_russia_forgive_any_german/)
[The beginning for NASA] (https://www.reddit.com/r/AskHistorians/comments/3o9xi7/why_did_the_us_create_nasa_instead_of_making/)