If you have
/scoreboard teams leave @e[tag=test] @e[tag=test0]
and there's no entity with the tag "test" the entity with the tag "test0" will not leave the team.
This only happens if the first player is a selector without result entity, if it happens to the second one, the 3rd, 4th, 5th, etc. will still leave the team, if the first is not a selector the rest also succeeds.
Probably the same reason as for MC-99758
The third argument is defined as being a selector. If this is the case and the selector includes multiple entities the command is executed for each entity. In this case for "@e[tag=test]", however like you said no entities which match the criterias exist. Only if no selector index is provided or the selector defines only a single entity the command is directly executed. As suggested in MC-99758 the "scoreboard teams" command should not return a selector index because when the command is executed it removes all matching entities at once and can also handle multiple selectors.