Note: when I say "neighbor", I don't mean it in the literal sense, but moreso in the Mr. Rogers sense, meaning "your fellow human" regardless of location or whether or not you have a personal connection with them.
I also find it interesting that you used the phrase "morally good form of serving a country", focusing on the country, rather than focusing on the people, but still mentioning the larger scale of caring for people who aren't in your immediate community. Medical doctors, generally speaking, care for people locally, with the exception of situations where remote care is feasible, for example with mental health. I think it would be of greater benefit to society if the licensing restrictions for something like mental health did not restrict the practice of that profession to a single country, but was expanded globally, but only if we also removed the profit motive from healthcare to avoid people everywhere only wanting to serve wealthy clients.
For cases where it is not feasible to care for people remotely, for example, if you are an anesthesiologist or if you work for any kind of in-patient medical care facility such as an old age home or a drug rehabilitation center (ignoring the fact that many drug rehab centers are corrupt, especially in the US given the profit motive), I don't know how it would be possible to serve a community outside of your immediate location, which makes what you said about "serving a country" confusing to me.
It is also possible to help people globally in large numbers with research and development of new medicines and medical techniques without ever meeting them or talking to them. In fact, Cuban doctors and researchers (along with researchers in other countries) already do this and export that knowledge to the rest of the world, which benefits all of humanity.
This idea isn't exclusive to medical care, either. For example, Canadian firefighters have fought fires across the border in the US in the past, since the area was close enough for them to be able to do so feasibly.
Another example of an idea that is nowhere near perfect in its implementation in its modern form, but has potential would be the ICC. If, for example, there were no borders, then it would be no problem for the ICC to arrest and try Netanyahu and Trump in an international court for war crimes, but since we have borders along with militaries and vast amounts of economic power inside those borders that protect their respective war criminal leaders, that has not been able to happen.