In practice, those are two different types of train travel. The former exists only in countries with a rail heritage. Where countries are genuinely trying to replace air travel with high-speed rail (credit to them, it's much more sustainable), the new train stations are alas a bit like airports for trains. You generally can't just turn up and hop on. In China you can't even get into the train station without a booking.
China requires showing identification to buy a long-distance train ticket.
Other countries I'm familiar with (Spain, France, Germany, UK, Japan) certainly do let you turn up, buy a ticket, and get on. It will cost more than buying earlier.