How to display WooCommerce category image in my category page banner as a background?

get_post_thumbnail return featured image for post. in order to get a thumbnail of the category, you need to fetch it through term meta.

global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true ); 
$image = wp_get_attachment_url( $thumbnail_id ); 

on the product page, since there can be multiple terms for a single product,
you need to fetch terms for that product first and then extract a thumbnail image of a specific term.