Because the treaty exists to prevent the very thing Israel did - covert nuclear arms development and covert sharing of know-how ( like Israel probably did with Apartheid South Africa).
It's like criticizing a country for not being in the Paris climate accord for their environmental record/refusing to lower emissions - yeah, that's kind of the the point.