Pakistan is playing in a geopolitical game that also involves the US, China, India and other nations much stronger than it. Large countries have a track record of being willing to throw small regional powers under the bus for their own gain. Pakistan, rightfully in my opinion sees having nukes as their only way to be dangerous enough that nobody will try to screw them out of their sovereignty. It's no surprise that they'd rather have nukes unsafely than not have them at all.