When a city (in the Promised Land) strays from G-d and worships other deities, the consequences are severe. “And all of its belongings you shall gather into its [main] thoroughfare, and you shall burn the city and all of its belongings completely with fire unto Hashem your G-d, and it shall be a mound [of destruction] forever; it shall not be rebuilt again” (D’varim 13:17). Rashi (and others) discuss what the words “unto Hashem your G-d” add. Isn’t it obvious that the destruction meted out on a city because of G-d’s commandment was done for G-d? Rashi says these words means that the destruction should be done “for Him (lit. for His name) and on His behalf.” But what is Rashi adding with these words?
Rabbi Yitzchok Sorotzkin, sh’lita, (Rinas Yitzchok III) implies that the word “for Him” used by Rashi teaches us that we must have G-d in mind when we do the actual burning (as opposed to, say, a pyromaniac doing it for his personal enjoyment). Rabbi Sorotzkin then asks why Rashi uses two words (“for Him” and “on His behalf”) when one should be enough. After all, elsewhere when Rashi explains a verse to mean that the action described should be done “for G-d” he only uses the first of these two words (or a form of it), without adding the second one. [The examples Rabbi Sorotzkin gives are the donations for the Mishkan (Sh’mos 25:2) and not working the land during sh’mitta (Vayikra 25:2), but the same can be said of Sh’mos 25:8 and 29:25, Vayikra 3:11 and 23:17 (if you look carefully), and Bamidbar 6:2 and 15:20 (see 15:19/21). Notice, though, that almost all of these are said regarding bringing offerings or something similar.] Rabbi Sorotzkin leaves his question unanswered.
There is a world of difference between making a personal sacrifice for G-d and doing something that adversely impacts others in the name of G-d. Unfortunately it is not uncommon for people, even (and perhaps especially) religious leaders, to (ab)use religion for personal gain (whether that gain be for prestige, power, financial improvement, or other personal benefits), so it is certainly appropriate to add an additional word when discussing destroying other people and/or their property so that we make doubly sure we are really doing it for the right reason — on behalf of G-d. In this case, although there is no obvious personal benefit (since all of the possessions of the inhabitants of the city are burned), there is a danger that those destroying a city of idol worship may not be doing it based on having a religious fervor to fulfill G-d’s will, but to compensate for a lack of confidence in their own belief system. Nevertheless, I think Rashi added the second word to his commentary to include more than just an admonition that such an act has be done for G-d rather than to cover for any religious insecurity.
In the Talmud (Sanhedrin 111b) Rabbi Shimon explains the words “completely, to Hashem your G-d” to mean that if we follow through with the judgment against a city of idol worshippers as prescribed in the Torah, which includes burning its contents completely, G-d will consider it as if we brought an “olah” offering, with is burned completely on the altar. It is likely that when the Targum translates the words “unto Hashem your G-d” as “before Hashem your G-d,” this is what is meant; when burning the city and its contents, do it “before G-d” because it is as if you are bringing an offering to Him (see Sha’aray Aharon). The first word Rashi uses, “for Him,” which is primarily used regarding things brought as offerings (and the like), is therefore appropriate if Rashi was referencing the comparison between burning this city “for G-d” and burning an offering for Him.
Tosfos (e.g. Da’as Z’keinim) explains why the city and all of its contents are burned “completely to Hashem your G-d” — “so that everyone is made aware that you destroyed the city for G-d, blessed is He, and not in order to benefit from its possessions.” By publicly burning everything (piling it up in the street, as opposed to leaving the possessions inside the houses to be burned when they are set ablaze), anyone seeing what’s happening will know that the reason the city was destroyed was because they sinned against G-d, not because others wanted to take their possessions; it was done “on behalf of G-d,” not for selfish reasons. The second word Rashi uses, “and on His behalf” (with a “vav” that indicates it is a separate thought from the previous word), fits well with this approach; not only should we consider burning the city an offering to G-d, but we must do it in a way that shows we are doing it for Him, and not for ourselves.
It is therefore possible that Rashi uses two words here, not just the one he uses elsewhere, to get across both ideas. We should do it “for Him” the way we do when we bring offerings (or donate to the Temple, or let the land go fallow every seven years, etc.), and do so in a way that makes it clear we are doing it “on His behalf” and not because of a personal agenda.