Make PHP work with HTML tags

From your code the proper structure would be

if ( is_singular() ) {
    if (get_post_meta(get_the_ID(), 'square_image', true)) {
        echo '<img src="' . get_post_meta($post->ID, 'square_image', true) . '"/>';
    } else {
        the_post_thumbnail( 'thumbnail' );
    }
}

We can make it a bit better by creating a variable that will contain the meta data so we don’t have to call the same function twice.

if (is_singular()) {
    if (!empty($square_image = get_post_meta(get_the_ID(), 'square_image', true))) {
        echo '<img src="' . $square_image . '"/>';
    } else {
        the_post_thumbnail('thumbnail');
    }
}

Now because our conditions contain just one line of code we can remove the {}

if (is_singular()) {
    if (!empty($square_image = get_post_meta(get_the_ID(), 'square_image', true))) echo '<img src="' . $square_image . '"/>';
    else the_post_thumbnail('thumbnail');
}

The official php documentation goes into details about working with php and html, see https://www.php.net/manual/en/faq.html.php.
This might also help, https://www.php.net/manual/en/language.operators.string.php, this goes into detail (not much) about how to concatenate strings