Garen and
kochen both mean "to cook (food)", but the emphasis is different.
Kochen is very general, covering all aspects of cooking and focusing on the entire process of preparing food to be eaten.
Garen emphasizes the thorough heating of food; food that is
gegart is "done" in the sense of completely cooked. Because
kochen can also mean "
boil",
garen must be used when referring to a heating process other than boiling.
Wir haben die Kartoffeln im Backofen gekocht would not make sense, since one boils potatoes on the stove top and not in the oven.