What was King Frederic thinking when he let Varian share a prison cell with Andrew?
I am personally of the opinion that that didn’t literally happen. Personally, I headcanon that they had neighboring cells, either right next to each other or across the hall from each other. I mean, look at all the times we’ve seen the cells. There are a lot of empty cells, all up and down the halls. Why would they shove two unrelated criminals - one a minor - into the same cell when there was plenty of space to not do that?
Also, why are you blaming Frederic? Do you honestly think he personally oversees the prisons? No, that’s what the Captain of the Guard is for. It’s called delegation. (And, might I add, the Captain was out of commission when Varian was arrested, so it could be argued that it was someone else’s fault entirely, even if it literally happened.)