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 ...
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.
It's a very good question. As far as I know, these relationships are taken for granted from the earliest times. For example, Yāskācārya's Niruktam (7.5) just states without explanation:
तिस्र एव देवता इति नैरुक्ताः । अग्निः पृथिवीस्थानः । वायुर्वेन्द्रो वान्तरिक्षस्थानः । सूर्यो द्युस्थानः ।
There are only three deities according to the school of Niruktam. ...
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
I have been ...
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 ...