This appears to be a bug that has been unreported for at least a few years! Just reported this week by a sharp eyed kiwitrees user.
It does require certain specific search criteria, but when these happen it is a significant error.
Fixing it has also highlighted a second bug that also needed to be fixed.
First bug. This results in adding extra marriage spouse details for people that were not married to the listed person. They were generally married to other siblings of that person, but simply because the names, dates or places of birth fit the report criteria.
Second bug. This is deeper in the code. It used male / female information for the listed person to choose whether their spouse would be husband or wife. Probably correct historically in 99%+ of cases, but it would ignore same-sex and trans-gender marriages and partnerships.
Both bugs are fixed by replacing the attached replacement file. The zip folder contains a “module.php” file, that replaces the existing one in kiwitrees/modules_v4/report_vital_records.