There is very little demand for making it easier to buy long distance train tickets such as Portugal to Latvia. Most railway journeys in Western Europe are for short (<100 km) or medium (100-1000 km) distances. Unlike for flights, booking systems have developed nationally because that's where almost all railway journeys are made. Often cross-border trains can still be booked, but not beyond that. However, some booking systems do interact. The German, Austrian, and Swiss railway systems are quite compatible, as are the French and Spanish systems. Despite the difficulties and the relatively low number of long distance international travellers, today there are websites and smartphone apps that connect to multiple national booking systems. Examples include thetrainline.com and raileurope.com. When it becomes even more complicated, there are dedicated travel agencies such as the treinreiswinkel in The Netherlands, which used to advertise tickets from Portugal to Vietnam. You can read more about thetrainline at seat61.com
In the distant past, there were many more long distance international services in Western Europe. The Orient Express was famous (and expensive), but there were others such as Sud Express and Nord Express, allowing people to travel from Lisbon to Stockholm with a change only in Paris. Since 2020, there has not even been a train from Lisbon to Madrid any more. With the advent of passenger airlines, long distance passenger trains service was reduced. With the advent of ultra-cheap passenger flights, it was reduced further. Night trains are quite expensive to operate because, unlike day trains, they can only run once per day (night) and are less full than day trains. Night trains suffer not only from cheap flights, but also from high speed rail. So although you can still travel from Portugal to Stockholm by train, you'll need many trains, many tickets, and probably several hotel nights.
With the climate crisis, there are cautious hints at a revival of night trains in Europe. ÖBB Nightjet has restarted on some routes that DB CityNightLine had dropped. The Swedish government is partly subsidising the new route Stockholm - Hamburg (starting 1 September 2022). The former German transport minister suggested reviving the Trans Europe Express. But we are a long way from being able to book international trains as easily as we can book complex airline tickets, and it seems this is not coming any time soon. In fact, in 2009, BBC News reported on the failure of a Europe-wide common booking system, which is apparently very expensive:
Railteam, the alliance of European high-speed rail operators, has shelved plans for a Europe-wide common booking system because of increasing costs.
The system would have allowed customers to book tickets for Europe-wide rail journeys in a single transaction.
The platform was due to be unveiled this year, but has been scrapped for the foreseeable future, according to Eurostar.
Railteam's other members include Thalys, SNCF and Deutsche Bahn.
"All seven high-speed operators thought the platform would be a good idea but once we started looking at the system in detail we realised that it would be very complicated and therefore extremely expensive." said Lesley Retallack from Eurostar.
At present, although travellers can book some Europe-wide tickets through the individual websites of Railteam's members, passengers often receive more than one ticket for journeys onward from the carriers' normal routes.
The new system would have created a one-stop-shop for tickets for complete high-speed journeys across Europe.
In India and Russia, among other places, long distance train journeys are slow, but booking is relatively easy and there are many night trains. It helps that those systems were built within one country with one booking system (in case of Russia, also linking with its shrinking number of post-Soviet friends). I would expect that, here too, long distance train usage is shrinking due to the availability of (cheap) flights, but I don't have factual information on this.