Change preview menu directory according to the category
I already solved, if someone has the same question I leave the answer below.
Create an update function
This will execute a function everytime the category is changed
def update_func(self, context):
    
    for pcoll in preview_collections.values():
        bpy.utils.previews.remove(pcoll)
    preview_collections.clear()

    pcoll = bpy.utils.previews.new()
    pcoll.images_location = os.path.join(os.path.dirname(__file__), &quot;images/&quot; + bpy.context.scene.MyEnum)
    preview_collections[&quot;thumbnail_previews&quot;] = pcoll
    
    bpy.types.Scene.my_thumbnails = EnumProperty(
        items=generate_previews(),
        )
        
    return None

In this code the value changed is the pcoll.image_location, where the previews folder is changed based on the category id
Set the update
Then we have to set the update function in the category menu
bpy.types.Scene.MyEnum = EnumProperty(
    items = [('cat1', 'Category 1', ''), 
             ('cat2', 'Category 2', ''),
             ('cat3', 'Category 3', ''),
             ('cat4', 'Category 4', ''),
             ('cat5', 'Category 5', ''),
             ('cat6', 'Category 6', '')],
    name = &quot;Category&quot;,
    update=update_func)