Search.php gets metadata from first post

I don’t think it’s just occasionally, that will always get you the post meta of the first post on a search results page, a taxonomy page, an archive page – any page where there are multiple posts, because the $post global will always be populated with the first post of any main query result.

EDIT-

if ( is_singular() ) :
    // we are viewing a single post or page
    $page_color = get_post_meta($post->ID, 'page_color', true);
else :
    // not a single post or page, use a default color
    $page_color="blue";
endif;