Because the consensus of the world community was that they don't want any more nuclear powers.
The States concluding this Treaty, hereinafter referred to as the “Parties to the Treaty”,
Considering the devastation that would be visited upon all mankind by a nuclear war and the consequent need to make every effort to avert the danger of such a war and to take measures to safeguard the security of peoples,
Believing that the proliferation of nuclear weapons would seriously enhance the danger of nuclear war, [...]
When it comes to sanctions, you have to differentiate between a boycott (refusal to buy), an embargo (refusal to sell), and a blockade (preventing others from trade). A blockade is an act of war, a boycott and an embargo are free decisions of the states -- a country has no right that others trade with it.
Various test bans tried to limit nuclear explosions by recognized nuclear powers and the development of new nuclear powers. This included a realization that making the recognized nuclear powers disarm very soon was impractical.