Why does backup cause two media sets in msdb.dbo.backupmediaset? After I take a SQL Server database backup using the script below, to a single media set, why do I see two Media SET IDs in table msdb.dbo.backupmediaset?

--take the full back up
BACKUP DATABASE Maintenance
TO  DISK = 'F:\MaintenanceTest\Maintenance1.bak', 
    DISK = 'F:\MaintenanceTest\Maintenance2.bak'
WITH FORMAT
, INIT
, MEDIANAME = 'Maintenance'
, NAME = 'Chapter15-Full Database Backup'
, COMPRESSION ;
GO

--query media set but get two media set IDs with the same name
select * from msdb.dbo.backupmediaset where name='Maintenance'
There is nothing in SQL Server protects you to reuse 'MEDIANAME'.
Taking your query and reusing for a a different database I will give you an example and that is the same reason you are seeing 2 records with same name.

BACKUP DATABASE [WideWorldImporters]
TO  DISK = 'C:\MaintenanceTest\Maintenance1.bak', 
    DISK = 'C:\MaintenanceTest\Maintenance2.bak'
WITH FORMAT
, INIT
, MEDIANAME = 'Maintenance'
, NAME = 'Chapter15-Full Database Backup'
, COMPRESSION ;
GO


Once backup is done :

 SELECT 
    media_set_id, 
    media_uuid, 
    media_family_count, 
    name, 
    description
 FROM [msdb].[dbo].[backupmediaset]




SELECT bm.media_family_count, bm.[name],bmf.physical_device_name
  FROM [msdb].[dbo].[backupmediafamily] AS bmf
  JOIN [msdb].[dbo].[backupmediaset] AS bm
  ON bmf.media_set_id=bm.media_set_id




Now doing the same again but changing the backup folder name to 'MaintenanceTest1' (different physical location).

BACKUP DATABASE [WideWorldImporters]
TO  DISK = 'C:\MaintenanceTest1\Maintenance1.bak', 
    DISK = 'C:\MaintenanceTest1\Maintenance2.bak'
WITH FORMAT
, INIT
, MEDIANAME = 'Maintenance'
, NAME = 'Chapter15-Full Database Backup'
, COMPRESSION ;
GO


For backupmediaset:


To see physical location: