For example, the US compensated Mexico for the Southwest territory at the end of the Mexican-American War.
Edit: Foes not goes.
Three possible reasons: to counter lingering ill-feeling on the part of the defeated nation which might one day be wanted as a friend; to counter domestic anti-war or anti-annexationist sentiment; or to present the transaction internationally as an agreed rather than imposed concession, or at least as one for which some recompense had been provided. I don't know which prevailed in 1848: the US had offered to buy Upper California for more than the eventual postwar cash settlement, but a trade involves a willing seller as well as a prospective buyer.