'Automatically assign product into existing category based on tags in functions.php

I tried looking for answers, but the related post doesn't help me. I have an existing Category without any products assigned in Woocommerce. I need to have a condition like what Shopify collections have if it's possible. So for example, a specific category will display products based on tag. Please see screenshot shopify screenshot sample



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source