(Russia is another big chunk of Europe but not included in the above map, though I think it may be the same grid with the Baltics)
For the question, measuring the flow of electricity is just normal power engineering, your home electricity meter does it as well. It's not so much the countries doing it though.
https://www.reuters.com/world/europe/baltic-countries-leave-...
E.g. trading https://www.energy-charts.info/charts/energy/chart.htm?l=en&...
Physical flows https://www.energy-charts.info/charts/energy/chart.htm?l=en&...
And it's not the same, so sometimes there is just "transit", although transit here should I guess be understood very loosely. I also assume they just know who paid for what.
Edit: although upon re-reading I think you probably asked something else. Sorry in that case.
They do know who paid for what. And actually anyone is able to know. It's a very regulated market, and most of its data is published, although I have to admit that if you don't know how to fetch it and read it, it's a bit hard to figure out by yourself.
You should be able to find published data on the ACER Remit Portal (https://www.acer-remit.eu/portal/home), ENTSO-E Transparency Platform (https://m-transparency.entsoe.eu/) and JAO website, Market Data tab (https://www.jao.eu).
For those countries connected, those providers can participate in other markets. France power plants can sell energy to Spain, but not to Portugal.
The trick here is that the price each opperator's offer is somewhat calculated based on opportunity cost. Wind turbines has no opportunity cost, since not selling the energy generated from the wind now does not make them able to sell it in the future (that energy can not be stored at industrial level). Then, all the accepted offers for a given forecast are paid at the price of the most expensive offer among them.
Each national grids has interconnections with other grids and you can measure the flow of power through these interconnections to know who is sending electricity or getting electricity from neighbours.
[1] https://en.wikipedia.org/wiki/Synchronous_grid_of_Continenta...
In terms of market deals, TSOs can't really do that. What can be done is measure the power flowing in lines connecting two grids, and summing them you get the total power exported from one grid to another.
full disclosure: I install high voltage switchgear for a living.
Like, if power from several different sources flows into a single substation before it goes to your home, you know exactly which source created the electricity you're using?
And if I purchase power from a 100% renewable company, is it always only electricity from their generators, never ever mixed in with power from other grid sources during downtime?
No, it's just best estimates based on generation, consumption and flow.
That's like taking a bucket of water out of the ocean and saying you know where it came from. Sure, it might have come from the nearest estuary, but odds are it got mixed in with water that originated somewhere else.
But I can tell you, each line is measured closely and billed accordingly. There is no guessing.
The question isn't even well-formed. It's like playing tug-of-war and asking exactly which player on the other team you're pulling against.