The deletion warning does not apply to the units you try to delete, but the units currently selected. Since it is possible to change selection while the dialog is open, this behavior causes you to delete other units than the one(s) that triggered the dialog.
Select something to delete which will trigger the deletion warning
Select something else using a keyboard hotkey
Confirm the deletion warning from step 1. The selection from step 2 will be deleted, instead of the selection from step 1.
Bug video 1 (simple bug reproduction: Select starting units, press shift-delete to delete all, press H to select town center, confirm deletion):
Video 2 (bug during a game where the deletion was unintentional):