Athithi Devo Bhava, which as you said roughly means "treat the unexpected guest as a god", originates from the Taittirya Upanishad of the Yajur Veda. Here's the whole hymn that it's taken from:
After having taught the Veda, the teacher instructs the pupil: 'Say what is true! Do thy duty! Do not neglect the study of the Veda! After having brought to ...
The seven sages who stayed in Janaloka till Vaivasvara Manvantara returned to earth (they could only return once) as sons of Brahma. It was during this Brahma Yagna, Brigu was born and he was raised by Varuna the ocean God and thus called Varuna Putra. Varuna was performing the sacrifice. This is explained in detail in Brahmanda Purana Volume 2 Chapter 1.
But what is the need to treat guest as God?
The exact answer to your above question is given in Skanda Purana Book 6 ,Nagara Khanda ,Chapter One Hundred Eighty six ( Importance of an Atithi).
It's said in Skanda Purana that Lord Shambhu and Lord Vishnu gets pleased with worship of Atithi including all the gods .Hence Atithi is full of all the devas.
In a guest all Gods are united. This is what the Shastras declare.
48. (A guest) should not be asked his family or his clan ; [Lit., his gotra] he should not be questioned as to learning or knowledge. [But
the host] should take him to be a god himself; for, in him are united
all the gods.
(Parashara Smriti, Chapter 1)
Further verses ...
I finally found where the Sama Veda quote is from. Here is the Sama Veda in Sanskrit. Near the beginning of the Aranya Archikah, Aranya Kandam section, the following verse occurs:
ahamasmi prathamajā ṛtasya pūrvaṃ devebhyo amṛtasya nāma |
yo mā dadāti sa idevamāvadahamannamannamadantamadmi || 594
Here is how this webpage translates the verse
The mantras are from the Shikshavalli of Taittiriya Upanishad, Yujur Veda.
It is part of the famous four phrase code of conduct.
मातृदेवो भव । पितृदेवो भव । आचार्यदेवो भव । अतिथिदेवो भव ।
matrudevo bhava | pitrudevo bhava | acharyadevo bhava | atithidevo bhava
Shikshavalli partly includes advice on ethics and morals given to graduating students ...