First of all, I am so sorry for your loss. I know the pain of losing a young cat suddenly, it's heartbreaking.
As previously mentioned, it's possible the UTI could have caused an obstruction, which could cause ARF (acute renal failure) and this caused the elevated potassium levels (hyperkalemia), which in turn, caused heart failure. Or, it's possible your cat had CRF (chronic renal failure), that caused hyperkalemia. Hard to say. Probably more likely the former, due to your saying the cat was fine and then not.
Hyperkalemia (excess potassium) may result from the inability of the kidneys of end-stage CRF cats to sufficiently rid their bodies of excess potassium. Hyperkalemia can stress the heart and could potentially cause heart failure and/or other associated problems.
No matter what elevated the potassium levels, it isn't unusual for heart failure to be the end result if the levels went high enough because severe changes in potassium levels disrupt normal cardiac function (whether it be too much potassium or too little) . It does sound like the kidneys did fail at some point, whether due to infection/obstruction or underlying disease.
Maybe call the vet and ask for a clarification, sometimes they don't really explain things very thoroughly and leave us just scratching our heads.
Again, so terribly sorry for your loss.