For both machines the COP is defined as the ratio of usefulenergy output to the total energy input. The useful energy outputs of the heat pump and the refrigerator are different, so their coefficients of performance are different.
What is useful depends on the purpose of the machine, or what good performance means. This is a matter of human choice rather than of thermodynamics. So although the COP is defined in the same way, the result is different because what is useful is different.
The purpose of the heat pump is to dump as much heat as possible at the hot sink. So the useful output of a heat pump is the total heat which is added to the hot sink : $Q_h=Q_c+W$. It does not matter whether this heat comes from the cold source or from the engine or motor which makes the transfer happen. So the COP of a heat pump is $$COP_{hp}=\frac{Q_h}{W}$$
The purpose of a refrigerator is to remove as much heat as possible from the cold source. So the useful output of a refrigerator or air conditioner is the net heat which is removed from the cold source : $Q_c$. The energy supplied to the refrigerator motor is not dumped in the cold source, so it does not affect the useful energy output of the refrigerator. The COP of a refrigerator is therefore $$COP_{ref}=\frac{Q_c}{W}=\frac{Q_h-W}{W}=COP_{hp}-1$$
This is the relation which you have found. Your first result is the COP for a refrigerator; the second is the COP for a heat pump.