There are multiple layers of the security.
Reward
The North Korean diplomats are privileged members of the North Korean society, typically since generations. The aren't suppressed, they belong to the suppressors.
And, getting the option to work in foreign countries, is one of the greatest rewards in their life. If they defect, they would betray it.
Social filtering
- There is a very complex system of hidden informers of the security police.
- Everybody has file by them generations back.
- Only the people with the best papers can get ever chance to work in foreign countries.
Rotation
It is not only in North Korea, this part is being done in all countries of the world. Working on an embassy, is not a job what one could do until retirement. They are periodically rotated, after maybe 2-4 years, all of them has to go.
"Democratic" countries do this typically with the (typically) 4 year long election cycle synchronously.
The goal is to avoid that a too strong bound between the diplomat and the receiving country would be built up.
Close family members remain as hostages
Everybody has at least one, but possibly more family member who can't ever leave the country. If a diplomat would escape, the system would get a revenge on them, any they know it.
Defectors will be hunted down
Kim Jong Un has let to kill his own cousin... being a North Korean diplomat, it would be a very clear signature, what could I await in the case of defecting.
The important thing is that not only a single "wall" is there. The human mind is a complex thing, and (for the greatest luck of the Humanity) not even a totalitarian dictatorship has really control over it. If only a single precaution would be applied, some of the diplomats would defect.
The trick is that there are multiple "defense walls", while already a single one would be enough for most people.
Despite that, some of the diplomats, yes, defect, but it is rare.
Yes, these defectors let the System to get revenge on their family members.
May God be merciful for us, never get into such decision situation.