I am going to take this question at its face value and address the question of a country X discriminating against the citizens of country Y, but not of those of country Z.
So, out of scope:
- privileges only granted to citizens of X within X, with no differences in treatment for citizens of friendly country Z or unfriendly country Y.
- (mostly) immigration and border controls to refuse Y citizens access to country X.
First, despite the big chumminess implicit in the question, reality in international relations is that no all countries get along equally well. Therefore states (X in my example) will legally decide to apply restrictions on citizens of other states (Y) under some conditions. This is not the same as a random person in country X suddenly deciding to discriminate against Y citizens on their own.
So, for example, immigration and border control wise, a number of EU countries have decided to keep out Russian tourists (note that Russia is mentioned in the Q). That is their right, a state certainly has the right to decide whom to allow on its territory. Schengen is a partial, revokable, lessening of that prerogative, with enforcement instead "subcontracted" to friendly states. Russia is not perceived as a friendly state by the EU countries in question, so they are limiting access.
Second, we need to discern exactly what kind of discrimination the OP is asking about. I asked about it but it was left in very vague terms
European banks are very unwilling to open bank accounts for Iranians/Russians
No examples were given.
It may come as a surprise that US citizens sometimes struggle to have bank services in the EU (due to IRS reporting requirements). Is that because European banks are racist against Americans? Or they are forbidden to do so? No, they just don't want to deal with the hassles. In this case, the problem is squarely on unreasonable demands by the US.
(in response to comment)
Why not force the bank to do it anyway? Just like employers are required to hire women of child bearing age? Because there is a legal public interest in hiring women of a child bearing age. This isn't a demonstrated public need here. And, in the case of "unfriendly country Y" concerns, forcing expediency would contravene national security goals.
Second, do European banks have reasons to be leery of Russian nationals, at least under certain conditions?
Swiss prosecutors have charged four banking executives for allegedly overseeing accounts that helped move millions of dollars of what is believed to be Russian president Vladimir Putin’s secret wealth, according to reporting by Swiss publication Tages-Anzeiger.
Which brings us back the American IRS issue above: a private entity may not want the hassle and may have good reasons to avoid it if worried about extra paperwork or getting itself in legal trouble.
Without seeing Putin funds at every occasion, in the context of generalized sanctions on Russian banks, a Russian expat who wants to wire some money to his retired mother in Russia will likely present some challenges that some banks would rather not deal with.
Similarly, sanctions against the export of dual-use goods may mean that a Russian-owned import/export firm is too risky for a bank.
Likewise, the UK has long been criticized for being a neat laundromat to Russian dirty money and is finally taking steps to clean things up.
In the EU, Iranian nationals have occasionally been caught trying to assassinate Iranian dissidents. Or in the US. Or in Turkey. So a bit of caution seems warranted.
It is quite possible that some resident (of country X) Russian, and Iranian, nationals are getting caught up in overzealous enforcement. Again, it would be up to the OP to give some concrete examples. To be honest, rather than hearing that about Russians and Iranians, there are more often grumbles about Chinese people being discriminated against.
This question would have more weight if it could show that the discrimination and unfair treatment is designed to outlive bad relations with country X.
It also conveniently skips that there are safeguards built into Western legal systems to avoid egregious abuse. For example, Trump's Muslim visa ban was rejected a number of times before it was considered sufficiently non-discriminatory.
A word of caution: Western countries do need to balance out looking out for their national interests against unfriendly countries with being careful not to repeat the racism that they engaged into in the past. For example, the rather notorious Japanese-American internments during WW2 (which Canada also did).
Finally, I sense some biggish rocks being thrown out of a fragile glass house when it comes to Russia, of all places, criticizing how foreign citizens of particular countries get treated.
Some U.S. officials expressed concern that Russia may have been using Griner as leverage in response to the Western sanctions imposed against Russia for its invasion of Ukraine. The former Pentagon official Evelyn Farkas expressed concern that Griner could be used as a "high-profile hostage" by Russia.[123][124] In May 2022, the U.S. State Department stated that they had determined Griner was being "wrongfully detained".[125] On May 15, it was reported that the United States and Russia would consider a prisoner swap, with Russia exchanging Griner for arms dealer Viktor Bout, who had served 10 years of a 25-year federal prison sentence in the United States.[126]