I wasn’t there. But the record we have states there was some warning (even from Balaam and others like him), and Amalek had a history of aggression towards the Israelites, attacking them at Rephidim and slaughtering a number of them while they were disadvantaged due to being tired out. Only the Gibeonites had the mind of submitting rather than meeting the Israelites in battle.
In what universe is genocide justifiable to combat "aggression"?
How is this moral?