In "Code of Honor," you have a civilization which is aware of and dealing with the Federation to begin with. This is not a primitive culture that is going to be contaminated by learning of the Federation and its technology. In fact, the Enterprise is specifically at the planet to engage in treaty negotiations. The prime directive would quite clearly seem to not apply in this case.
In addition, the root of Picard's interference began when one of his officers was kidnapped off of the Enterprise. Surely the prime directive would not apply to a society which is already aware of and in contact with the Federation, is in treaty negotiations with them, and then commits a direct attack against them. If the prime directive applied in that scenario, it would give every single space faring species carte blanche to attack the Enterprise at will.