In general, there are situations where your nationality actually affects whether something is a crime or not or how severe. For example, treason (usually only citizens can commit treason, foreigners can't), illegally entering a country (usually only foreigners can, not citizens). In Germany, insulting a foreign head of state is illegal - but only for Germans.
And there will be other cases, where the laws of a country are so strict that lawfully convicting a foreigner might lead to trouble with the other country, and avoiding that trouble might be more important than upholding the law and getting a conviction, so a foreigner might be removed from the country instead of being thrown into jail for example.