Create a variable with string, array or multiple values

the last $file takes priority over the previous

That’s because you assign the new value to the $file variable at every line.

The only way I see you can do it by using the array:

<?php
// define directory list
$directories = array(
    'home',
    'pages',
    'blog',
    'single-posts',
    'products',
    'templates',
    'products'
);
// run through directories and return the result for each of them
foreach($directories as $directory) {
    // create path for each directory
    $path = CUSTOM_OPTION_BACKEND_TEMPLATES_PATH . "https://wordpress.stackexchange.com/" . $directory . "https://wordpress.stackexchange.com/" . get_post_meta( $post->ID, '_wp_page_template', true );
    // return path if file exists
    if ( file_exists( $path ) )
        return $path;
}