The Space Race is a second option to win the game, besides eliminating all other civilizations. If your spaceship arrives first at Alpha Centauri, the game is over and you have won.
Before you can build spaceship parts, the Apollo Program wonder must have been built by any player. You also need specific technologies to build the different spaceship parts: see the help texts for Space Structural, Space Component, and Space Module, under City Improvements.
If the success probability is below 100%, some fraction of the people on board may not survive the journey. This reduces the score bonus from the spaceship, but it still counts as a win.
If the capital of a civilization is captured, a spaceship that has been launched will be lost, so defend your capital well!
TIP: If an enemy civilization has launched a spaceship, try to quickly build a light spaceship with many propulsion units that will arrive earlier. The only other option is to capture their capital.