How to add a material to the active material slot with python
The list of materials that shows in the material properties comes from

obj.material_slots


The index for the one that is selected in that list is

idx = obj.active_material_index


using that you assign a material to that slot with

obj.material_slots[idx].material = mat