You're missing a bit of the back story and context with that passage, by the way. For example, Exodus 17 verse 8:
"The Amalekites came and attacked the Israelites at Rephidim."
and earlier in the chapter you quoted, verse 2:
"This is what the LORD of Hosts says: ‘I witnessed what the Amalekites did to the Israelites when they ambushed them on their way up from Egypt."
It's not unreasonable to imagine that the Amalekites might have intended to carry out a genocide against the Israelites (something which the Israelites seem to have been uniquely disproportionately targeted with in history), and that an omniscient God might have known that putting an end to the Amalekites would be the most peaceful solution in the long run.
As for the cattle, perhaps God didn't want the Israelites to make a huge profit from their defensive war, lest they be tempted to start some other wars to profit more.
"The Amalekites came and attacked the Israelites at Rephidim."
and earlier in the chapter you quoted, verse 2:
"This is what the LORD of Hosts says: ‘I witnessed what the Amalekites did to the Israelites when they ambushed them on their way up from Egypt."
It's not unreasonable to imagine that the Amalekites might have intended to carry out a genocide against the Israelites (something which the Israelites seem to have been uniquely disproportionately targeted with in history), and that an omniscient God might have known that putting an end to the Amalekites would be the most peaceful solution in the long run.
As for the cattle, perhaps God didn't want the Israelites to make a huge profit from their defensive war, lest they be tempted to start some other wars to profit more.