The matter of Soviet nukes being stationed in Ukraine was so existential for Russia that a refusal to give up the nukes eventually would have led to a full-on invasion by Russia.
Ukraine had only been independent for a couple of years at that point, so they did not have the necessary military structures to defend themselves like they are doing this time around. The US would not have engaged in full-on war with Russia just to let Ukraine keep the nukes – at the time, nobody knew how Ukraine was going to develop, so the West preferred Ukraine giving up their nukes to avoid the scenario of a rogue post-Soviet country with nuclear weapons.
You have to remember, at the time, Ukraine was not yet seen in the West as this brave independent anti-Russia that it is perceived as today.
Finally, the Ukrainians could not have used those nuclear weapons in the hypothetical invasion. The nuclear command & control was headquartered in Russia, so the Ukrainians didn't have access to the launch codes. Even if they had somehow managed to circumvent that and actually used the nuclear weapons, that definitely would have united Russia and the West against Ukraine.