> The presumption you're making is that a country would never spend money for the public good, where that is defined to include the entire human race, rather than just nationals.
I think in general this is the case? Obviously governments budget for foreign aid, and also contribute to collective efforts e.g. climate change or (relevant to this discussion) EU funds such as Horizon 2020. But I don't think any governments do/should consider "the public" as meaning "the entire human race".