How can I count ACF sub_field with a certain value

PHP’s count() function is generally used to count elements in an array, but you’re counting the value of a string, and that always returns 1. You can just add 1 in your if statement.

Something like this:

if (have_rows('candidates')):
  $total = 0;
  while (have_rows('candidates')): the_row(); 
    $position = get_sub_field('candidate_position');
    if ($position == "Mayor") {
      $total++;
    };
  endwhile;
  echo $total;
endif;

Other than that, the code actually looks right. Where are you initializing $numrows and where are you checking the value? Do you get a different value using the code above?