@Aboelabbas gave me the hint I needed. Although I don’t really know what I did different, here is the working code for all three modes I need:
<?php
add_filter('query_vars', function ($query_vars) {
$query_vars[] = 'mode';
return $query_vars;
});
add_action('init', function () {
add_rewrite_rule(
'(.+)/buchung$', // Rule for URLs ending with "/buchung"
'index.php?pagename=$matches[1]&mode=booking',
'top'
);
add_rewrite_rule(
'(.+/[^/]+)\.xml$', // Rule for URLs ending with "/anything.xml"
'index.php?pagename=$matches[1]&mode=xml',
'top'
);
add_rewrite_rule(
'(.+/[^/]+)\.json$', // Rule for URLs ending with "/anything.json"
'index.php?pagename=$matches[1]&mode=json',
'top'
);
});