Filter entries by other entry
If I correctly understand your question, you want to show each location with at least one vacancy, and the number of vacancies for that location? I don't really get what block.vacancySelected is?

The way I would do this:

{# get all locations #}
{% set allLocations = craft.entries.section('locations').all() %}

{% for location in location %}
    {# get a vacancy count for this location #}
    {% set vacancyCountForLocation = craft.entries.section('vacancies').relatedTo({
        field: 'locationFieldHandle',
        targetElement: location,
    }).count() %}

    {% if vacancyCountForLocation %}
        {{ location.locationName }} ({{ vacancyCountForLocation }})
    {% endfor %}
{% endfor %}


To prevent loading all locations, even if they have no vacancies, you could also try (untested):

{# get all locations, but only if they have related vacancies #}
{% set allVacancies = craft.entries.section('vacancies').ids() %}
{% set allLocations = craft.entries.section('locations').relatedTo({
    field: 'locationFieldHandle',
    sourceElement: allVacancies,
}).all() %}

{% for location in location %}
    {# get a vacancy count for this location #}
    {% set vacancyCountForLocation = craft.entries.section('vacancies').relatedTo({
        field: 'locationFieldHandle',
        targetElement: location,
    }).count() %}

    {{ location.locationName }} ({{ vacancyCountForLocation }})
{% endfor %}