In the UK there are many prepurchase discounts on rail tickets, but you will need to use a source that is designed for Brits, not Americans or you will be charged more. In most European countries the price is the same whenever you buy it.
There is one exception that I have only used on one short trip, and that is the unofficial sales. In that case the conductor asked if we wanted to travel with a ticket or without a ticket and quoted different prices for each. Most of the people in the compartment opted to travel without a ticket for a much cheaper price, which went directly in the conductors pocket. This was in Moldova. In Ukraine, one time we went up to the ticket booth which was on the platform and bought tickets but noticed a lot of local people showing up for the train but not buying tickets. In fact almost no one went to the ticket window. When we got on the train, we noted that people were paying the conductor directly, and one in our compartment was going to the same destination and paid the conductor half of what we paid. I have also had trips in Romania where the sleeping car attendants have asked if we will be travelling back the other direction, and if so to see them rather than buy a ticket and we would get a ''big discount'. But although it seems to be standard practice in parts of eastern Europe, I would not take the risk on a major or even medium trip.