Python - Iterate over each object and unwrap - Problem
From the first script, just manage the selections in order to use the bpy.ops on each one separately:
Deselect all once you get the selected ones.
Select before using bpy.ops and deselect after that.
sel_objs = [obj for obj in bpy.context.selected_objects if obj.type == 'MESH']

for obj in sel_objs: # &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
    obj.select_set(False) # &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;

while len(sel_objs) &gt;= 1:  
                  
    obj1 = sel_objs.pop() 
    
    obj1.select_set(True) 
    
    bpy.context.view_layer.objects.active = obj1
     
    bpy.ops.object.editmode_toggle()              
    
    bpy.ops.mesh.select_all(action='SELECT')
    bpy.ops.uv.select_all(action='SELECT')
    bpy.ops.uv.cube_project(cube_size=0.333957)            
    bpy.ops.uv.average_islands_scale()
    bpy.ops.uv.pack_islands(margin=0.01)
    
    bpy.ops.object.editmode_toggle()

    obj1.select_set(False) # &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;