SGLT2 is a Na+/Glucose co-transporter, like SGLT1 in the gut (oral fluid tx for Cholera). If you block it, less Na+ is reabsorbed on the basolateral Na/K pump. And so, less K is transported from the interstitium into the tubular cell to be excreted. Hence, hyperkalemia. Careful with other hyperkalemic drugs (ACE/ARBs).
Diabetes is itself an independent risk factor for hyperkalemia.