The two terms have held different meanings at different times, eg. the Israelites were referred to as a 'goy kadosh' (holy nation) in the Bible, but today the term 'goyim' more frequently is used for non Jews. Language changes over time, and this is true within the Tanakh too, as terms' meanings change as a result of the passing of time between the various authors.
In terms of the differences between Deuteronomy and Numbers, as you pointed out, again it is the matter of different authors. Scholars frequently date Deuteronomy as a "later" text (that is, in relation to the rest of the Pentateuch). For example Moshe Weinfeld, in "Deuteronomy--The Present State of Inquiry" (Society of Biblical Literature, 1967), argues in favor of the theory of W. M. L. de Wette, who claimed as early as 1805 that Deuteronomy's law code matched the reforms of Josiah and specifically the efforts to centralize the Temple cult in Jerusalem. Josiah's discovery of a "book of the law" and his efforts to reform Israelite religion (2 Kings 22-23) are commonly taken to refer to the "discovery" of a fifth book of Moses. In this light, differences in language between Numbers and Deuteronomy (not to mention the rest of the Pentateuch, e.g. the commandment to שמור vs. זכור the Sabbath) come into focus.
When the terms are used in the same verse, we can see them as complementary terms. As @YEZ pointed out, one example is Chronicles 1 17:21, which reads:
וּמִי כְּעַמְּךָ יִשְׂרָאֵל, גּוֹי אֶחָד בָּאָרֶץ: אֲשֶׁר הָלַךְ הָאֱלֹהִים לִפְדּוֹת לוֹ עָם, לָשׂוּם לְךָ שֵׁם גְּדֻלּוֹת וְנֹרָאוֹת--לְגָרֵשׁ מִפְּנֵי עַמְּךָ אֲשֶׁר-פָּדִיתָ מִמִּצְרַיִם, גּוֹיִם. כב
In the first phrase, "U-mi ke-'amha yisra'el, goy 'ehad ba-arets," we find a classic example of Biblical parallelism, the main rhetorical and poetic form of the Hebrew Bible. In part A of the phrase, the term "Am" is used, and in the second, its synonym, "Goy," replaces it.
As E.A. Speiser has argued, the terms have complementary meanings. "Am" does not exclusively reference the Jewish people, but it is also the only term to be used on conjunction with the tetragrammaton, e.g. Am YHWH - the people of God. "Am" has more of a relationship with family and kinship, and perhaps can be best translated as "people," whereas "Goy" is a nation, which can be established, built, destroyed, etc. In the end, Speiser argues that Israel was both an "Am" and a "Goy." Though the terms had different meanings, they were complementary and together characterized the Israelite people.