Drupal PHP weird error with && operators and if statement

I’m developing a hook to update a field on a content type every time the node is updated by the user using the
"hook_node_presave", but the php compiler seems to not enter to the right spots. Here is the code:

function test_node_presave($node){

$nids = Drupal::entityQuery('node')->condition('type','vehiculo')->execute();

if (($node->getType() == 'vehiculo' && $node->field_version_modelo != count($nids)+1)) {
    $node->field_version_modelo = count($nids)+1;
  $node->field_version_modelo = count($nids)+0;

The ‘$nids’ variable is an array of all the ‘vehicle’ nodes i have created, and in the if statment i just say that if the type of the node is ‘vehicle’ and the value of the field ‘field_version_model’ is not equal to the count of vehicle nodes, assign that value to the field.

The problem comes when the code never reaches the else statement, even if the value of field_version_model is equal to count($nids)+1

So the value gets asigned 5 every time.

introducir la descripciĆ³n de la imagen aquĆ­