When a treaty isn't enforceable or has no real consequences of being non-compliant its simply better to stay in it, unless the goal is to make a statement by leaving. Announcing intent to leave a treaty sends a message that you aren't willing to cooperate on whatever the treaty was about. Leaving also generates a bigger news story than simply being non-compliant, when a country is non-compliant with a treaty they can downplay the negative press. A country can disagree with the scope of what illicit drugs are, but still be committed to preventing the spread and abuse of those illicit drugs they do agree with.
Leaving a treaty about refugees sends the message you aren't interested in helping any refugees ever and not willing to negotiate about it at all. Being a non compliant member of the treaty leaves room for negotiation, you can support aiding refugees but object to the scope of that aid and still be helpful to a degree.
The UN was created to create an environment of international cooperation and harmony to prevent future world wars, genocides, and promote development of non-industrialized nations. It was also created in such a way that it can't really interfere too much with the actions of superpower nations. In order to achieve these goals there needs to be a sort of collective agreement/delusion that the UN is really more powerful than it actually is. Countries outright leaving treaties is a fairly major blow to maintaining that illusion and the stated goals of the UN, while quietly being non-compliant keeps everyone happy.