Several ways it could happen. To start, recognize that Pakistan’s “friendliness” to the West is questionable, at best.
So even if the government doesn’t do it itself, there are many anti-American-sympathetic individuals in the nuclear establishment and military (remember the ISI?) who could hand over helpful info or technology, or even defect.
An military attack on a country has a surprising power to suddenly unite former rivals and completely change the picture. That’s why I say an American attack on Iran is stupid, based on the strategic fundamentals.