If you try to use the add_rewrite_endpoint function and add more than one query variable at once, WordPress just loads all data for the first variable it finds. For example, /city/new-york/product/iphone-11 is understood as:
$city = “new-york/product/iphone-11”
$product = “” (empty)
There is no way to fix this with add_rewrite_endpoint alone, and you’ll need to use more complex rewrite rules using add_rewrite_rule.