Update a Referenced Node with a value from the node referencing it
Thank you both @GiorgosK and @4k4, for pointing me to the right direction! Here is the solution:

use Drupal\node\Entity\Node;


function my_module_entity_insert(Drupal\Core\Entity\EntityInterface
$entity) {
 if ($entity-&gt;getEntityTypeId() == 'node' &amp;&amp; $entity-&gt;bundle() ==  'iamoriginal') {
   if (!$entity-&gt;field_my_reference-&gt;isEmpty() &amp;&amp;   !$entity-&gt;field_number-&gt;isEmpty() &amp;&amp;
 !$entity-&gt;field_hide_me-&gt;value) {
  _my_module_update_parent($entity, 'add');
 }
 }
}


function my_module_entity_update(Drupal\Core\Entity\EntityInterface $entity) {
 if ($entity-&gt;getEntityTypeId() == 'node' &amp;&amp; $entity-&gt;bundle() == 'iamoriginal') {
$original = $entity-&gt;original;
if (!$entity-&gt;field_my_reference-&gt;isEmpty() &amp;&amp; !$entity-&gt;field_number-&gt;isEmpty() &amp;&amp;
  $entity-&gt;field_hide_me-&gt;value != $original-&gt;field_hide_me-&gt;value) {
  $operation = ($entity-&gt;field_hide_me-&gt;value) ? 'sub' : 'add';
  _my_module_update_parent($entity, $operation);
}
 }
}

function _my_module_update_parent($entity, $operation) {
 $ref = $entity-&gt;get('field_my_reference')
   -&gt;first()
   -&gt;get('entity')
   -&gt;getTarget()
  -&gt;getValue();
 if ($ref-&gt;hasField('field_number_of_originals') &amp;&amp;        $ref-&gt;hasField('field_total_value')) {
$total = $ref-&gt;field_total_value-&gt;value;
$count = $ref-&gt;field_number_of_originals-&gt;value;
$number = $entity-&gt;field_number-&gt;value;
switch ($operation) {
  case 'add':
    $total += $number;
    $count++;
    break;
  case 'sub':
    $total -= $number;
    $count--;
    break;
}
$ref-&gt;set('field_total_value', $total);
$ref-&gt;set('field_number_of_originals', $count);
$ref-&gt;save();
 }
 }


If a user adds a new node of the post type "iamoriginal" then the value of the field_number is added to the refrenced node's field_total_value and +1 to the field_number_of_originals. If he later wants to disable the original node ,he gives a value to the field_hide_me and the previously added values to the referenced node are abstracted. Thank you again for your help!!!