I'll answer about Martinez. The station is nice and has friendly and knowledgeable agents, but really minimal food service (coffee, candy, a few pastries sometimes, not much more and not open very late ... sometimes she has locally made sandwiches or cookies). The depot restrooms require tokens (from the desk, just get one when you arrive so you'll have it if you need it later). I've never seen many homeless people in the area but there must be some because there are regular fatalities from transients walking the tracks, which are on a much easier route than the hillside road.
If you walk east along the tracks, there is a waterfront park with a steam engine, some paths and benches, marsh with birdwatching, marina, bait shop, etc. That is opposite side of tracks from depot. You won't have enough time but that park extends quite a distance along Carquinez Straits both directions.
Same side of tracks as the Amtrak depot is the old SP Depot, which the historic society has been putting money into. The city owns the SP building but I don't know if it is occupied yet, it is a great location and the historic society is not the only group that would like to use it. The SP Depot and the locomotive are roughly across the tracks from each other, there is also a hot dog place on the corner there.
Downtown is on the same side of the tracks and walkable, including decent restaurants. Martinez is the county seat (courthouse, jail) so keep your eyes open but it is generally low key and safe all night long.
Use your smartphone if you wander, Martinez rolls up the sidewalk pretty early, many of the restaurants are lunch only.