There are a few issues that should be pointed out before we can try to understand these laws. There is a difference halachicaly between stealing and damaging vs returning and reparations. Whereas stealing and damaging is not allowed whether done to a Jew or a nonJew, payment and reparation is reserved for members of the Jew club. A similar point is mentioned in a note on the shulchan aruch in the beginning of the laws concerning interest. Hopefully after the proliferation of insurance policies and buyers clubs this idea will be more readily accepted. However this idea that a Jew would not pay reparations for damages his ox caused to a nonjew is recorded in the Talmud as causing animosity between its and the nonjews.
Back to our Ramma. The first situation the Ramma discusses is tricking the nonjew, such as confusing him in his reckoning. In this situation what ends happening is an agreed upon transaction with misgivings. A transaction with misgivings between Jews is either not valid or there is a need to repay the one who got ripped off, as we find in laws of onaa and mekach taos. Again, these are laws reserved for members of the Jew club. This allowance to trick the nonjew is not a simple permission as the Ramma himself ends off that some say this is not allowed unless the nonjew mixes himself up. The Shach. #3 quotes the Maharshal who says even in this situation the Jew must tell the nonjews 'see, how i am relying upon your reckoning', so as to absolve himself from all involvement in this mistake.
The Second case in the Ramma gets back to our discussion before about payment and reparation. To repeat with clarification, stealing from a nonjew is not allowed, possibly even on a biblical level see Shach #2, with the need to return a stolen item depending on that classification. However, the payment of a debt is different. This is quantified in Shach #3 in the name of Maharshal, a debt such as an old loan or a tax is what is allowed to be ignored (הפקעת הלואתו) as long as there is no desecration of Hashem's name. This payment of an old debt is the case of the Ramma, but a debt for a transaction at the time of purchase cannot be ignored and would be similar to stealing, the Maharshal ends off by adding it would be as if you took what is his against his will and you stole his gold away from him.
This is all different than the laws concerning members of the Jew club where payments of old debts cannot be ignored.