San Francisco International Airport (SFO) is the standard gateway — 30 km north, around half an hour by car or 50 minutes by Caltrain plus BART. San Jose International (SJC) is closer (25 km south) and often cheaper for domestic flights. Caltrain runs frequently from both San Francisco and San Jose stations directly to Palo Alto station and the smaller California Avenue station.
A car is useful for exploring Stanford's perimeter, the Baylands, and the foothills, but downtown Palo Alto is dense enough to walk if you stay near University Avenue. Bicycles are everywhere and the city's bike infrastructure is unusually good for the United States.