In the first Gulf War, we placed the Patriot batteries around Israel, as they said that if an Iraqi biological or chemical SCUD attack hit Tel Aviv, they would vitrify Baghdad.
Having nukes doesn't prevent _anyone_ from attacking you, but it does constrain those attacks to conventional means. And what if you pulled off a decapitation attack against Tel Aviv? Well their fleet of nuclear capable subs would make you pay.
It ain't Iran.
Maybe Nukes do not prevent terrorism, or gorilla warfare.
Having Nukes would prevent a large strike from another state, like what US just did.
Nobody is doing this large scale of bombing on any of the nuclear powers.