The grammatical construction 〜かと思うと/〜かと思ったら doesn't have anything to do with what someone literally thinks, imagines or believes. It means "just when…/no sooner than…"
#Japanese #日本語