Even if you have two items, they can be the same?
<?php if ($page->listing()->toStructure()->isNotEmpty()) {
$items = $page->listing()->toStructure()->sortBy('race_km', 'asc')->filter(fn($item) => empty($item->race_km()->value()) === false);
$min = $items->first()->race_km();
$max = $items->last()->race_km();
echo $min === $max ? $min . ' km' : $min . ' à ' . $max . ' km';
}