Although this can simply be explained by "video game logic" we are video game theorists, we don't take that for an answer. So throughout playing the zelda games I have always wondered how link heals by running into a heart. My theory is that link, is able to heal by absorbing the life force from fallen enemies. The hearts simply represent the life force. Link is able to store as much life force as he has containers for them like heart containers. This is also why grass drops hearts as well, it may not have a heart but it has life force. This means red potions also contain life force.