I have no definitive answer, but I can point to a few differences.
First, as you noted, Poland of 1665-1660 had indeed very little in the way of allies, whereas in 1700-1712, they were at least allied to Russia, and in some manner to Saxony. However, the Polish-Saxon king Augustus had only declared war as Polish king, so while Saxony was a safe home ground for him, he could not use it fully. Even so, the war did not end until Charles decided to ignore this technicality and invaded Saxony. The Russians, for their part, were largely busy trying to capture and hold on to land around present day St Petersburg, and sent relatively little help to Poland (they were probably happy that two of their strongest neighbours duked it out with eachother; they would certainly make sure to gain from the weaknesses of both later).
Second, in 1665, Sweden was the aggressor, while in 1700, Poland was the aggressor. It is possible that the Poles found it easier to gather to defend against an enemy that they did not feel had been forced on them by their king.
Third, the Swedish army was wastly different. The army of 1665 was essentially similar to the one that had fought the Thirty years war: mostly mercenaries and some conscripts. It was thus dependant on plunder (this was part of the reason the Swedes invaded from the start: they needed a new war to pay for the old one), and needed a peace which guaranteed enough money that it could be paid off. The army of 1700 mainly consisted of croft soldiers, which could be kept in the field almost indefinately, were very well drilled, and had no special conditions for stopping to fight (more on this below). The main drawback was that it was hard to replace if it suffered defeat, which would later prove to be fatal, but worked very well during this part of the war. Thus, the army of 1700 was overall more well trained, more disciplined, and was not about to complain about lack of pay. This made it possible for Charles to fight where and when he chose, even in the face of setbacks.
Fourth, Charles XII was a vastly different creature from Charles X Gustaf, and their goals were different. Charles XII saw it as his mission to punish Augustus until he no longer was a threat to Sweden. Charles X Gustaf mostly wanted to conquer and plunder, preferably as quickly as possible. However, once the war had dragged on for several years, with no peace in sight (Poland's political division for once was a kind of advantage), and the opportunity came, he prefered to cut his losses in Poland and try to march against Denmark instead (with results beyond what anyone could have reasonably expected).
Thus, while I can not really point to any deciding differences on the Polish side, the Swedish armies were so different that they might be considered from different countries. One wanted to make a quick grab of land and valuables, while the other wanted to make sure that Poland learnt a lesson about going to war with Sweden. When the first failed in it's goal, it was better to move on to another target, while the latter could keep trying until it was soundly defeated.
The above was written of the top of my head, but a good account of the deluge is Peter Englund's Den oövervinnerlige, "The Invincible" (not sure if it is available in English). For the Great northern war, Frans G. Bengtsson's biography Karl XII:s levnad, "The life of Charles XII, King of Sweden" is somewhat old, not very scholarly, but for the most part very readable.