I am not sure if this question has been asked before but anyway, Consider these two examples:
h[x + h[y]] /. h[u_] :> g[u] (*g[x + h[y]]*) h[x + h[y]] /. h :> g (*g[x + g[y]]*)
In the first one, the rules apply starting from outer level and once it applies then it stops. however, in the second example the rules apply up to the lowest level.
any explanation why there is different in the way ReplaceAll work.