Heat spontaneously flow from Hotter body to the Colder body when no external work being performed on the system. But in the case of Refrigerator external work is performed by Heat Pump, which takes certain amount of heat from colder body (say Q1) , a work (say W) is done on it by the surrounding and a total heat/energy W+Q1 is supplied to some other body which is hotter than the colder body but not with respect to the pump and surrounding work done (W+Q1). Thus in case of refrigerator though heat is supplied from colder body to hotter body but the process is not direct but through a Heat Pump.