Some EU countries offer scholarships to attract good foreign undergrads and grad students to their universities. The whole point is that they stay afterwards, and they try really hard to keep them. It's been proven to be quite economically profitable, see e.g. [1]. I've never understood what's the point of attracting good students if you don't want to keep them later on, unless you have overcapacity and sell education services. But that would not make sense for top universities where there is a fierce competition for spots.
[1] https://www.dtu.dk/english/newsarchive/2022/11/udenlandske-s...