Warning: sizeof (): Parameter must be an array or an object that implements Countable, On products pages

Let’s take a look at get_the_terms Codex page. We can find there that this function may return:

(array|false|WP_Error) Array of WP_Term objects on success, false if
there are no terms or the post does not exist, WP_Error on failure.

So your code will work correct only in one case – when the function returns an array of terms.

But it may also return a WP_Error if any error occurs or false if there are no terms for that post in given taxonomy.

So yes – you should always include proper error checking in your code. It may look like this:

global $product, $post, $smof_data;
$cats = get_the_terms($post->ID, 'product_cat');
$cat_count = ( !empty( $cats ) && ! is_wp_error( $cats ) ) ? count($cats) : 0;
$tags = get_the_terms($post->ID, 'product_tag');
$tag_count = ( !empty( $tags ) && ! is_wp_error( $tags ) ) ? count($tags) : 0;