The cake would burn if I didn't go to the kitchen.
(you're telling a story about the past, in which you are faced with a choice about going to the kitchen, and you are aware of the consequences if you don't)
Thе cakе would havе burnt іf І didn't go to thе kіtchеn.
(not grammatical)
Thе cakе would havе burnt іf І hadn't gonе to thе kіtchеn.
(you're telling a story about the past, in which you went to the kitchen, for whatever reason, and prevented a cake from burning)