The answer happens at the thick ascending loop of Henle (in the nephron). One of the (passive) pumps there takes 1 Na+, 1 K+ and 2 Cl- ions from the tubular lumen into the cell.
This is the major way that Na+ is absorbed in this area (but not the major way overall - most sodium is reabsorbed much earlier). However, there is a problem: there are much less K+ than Na+ ions, and if K+ runs short, the pump doesn't work. The body gets around this by allowing some K+ to leak back from the cell (where it's just been transported) into the tubular lumen again. Thus, the pump can continue to operate.
Already, the mechanism of polyuria in hypokalaemia is obvious. If there is low potassium in the blood, there will be low potassium in the tubules (since tubular fluid is an ultrafiltrate of blood). And if there is low potassium in the tubular fluid, there won't be enough to allow the
1Na+/2Cl-/1K+ pump to work (even if some does leak back into the lumen).
With less Na+ absorbed due to the above pump's failure, there is more Na+ in the tubular lumen. And since Na+ is so osmotically active, water is retained alongside it: polyuria. A similar thing happens in the collecting tubule later one (this time with a Na+/K+ pump).
And hypercalcaemia? The high tubular concentration of calcium makes the net charge of the tubular fluid more positive (Ca2+). This tends to inhibit the back-leak of K+ ions, since they are also positively charged, and 'like' charges repel. Again, this inhibits the above pump, resulting in more Na+, and thus more water, in the lumen.
Compounding both of these states (hypercalcaemia and hypokalaemia) is the odd fact that the kidney also responds less well to ADH, a hormone secreted by the hypothalamus that would normally increase water reabsorption. Thus both of these states are causes of 'nephrogenic diabetes insipidus', but the jury's still out on quite why. Regardless, this makes the polyuria worse.