Not a reference to a Trinity of Persons
Among Trinitarian Christians, the standard explanation of God referring to himself as "us" in Genesis 1:26 and Genesis 3:22 is that it refers to the Trinity of Persons: Father, Son, and Holy Spirit.
However, this explanation is anachronistic.
The doctrine of a Trinity of Persons in God did not emerge and become codified into doctrine until several centuries after Christ. These early stories in Genesis come from many centuries before Christ. They were composed in Hebrew and Jewish culture, which did not have a concept of a Trinity of Persons in God. Therefore the Trinity could not possibly be what the text meant in the minds of its original human authors and readers.
(I'm not denying that the Bible is the Word of God. I'm simply saying that it was written in particular cultures, by the hand of various human beings in those cultures. Therefore its original meaning must be evaluated based on the meaning that the text would hold in those cultures.)
The Hebrew word elohim
The use of "us" to refer to God must be explained in connection with the Hebrew word elohim, commonly translated as "God." This word is plural in form. It usually takes singular verbs, pronouns, and so on. But occasionally, as in Genesis 1:26 and 3:22, it takes plural verbs and pronouns.
Here are some explanations of the meaning of the plural that are more supportable based on the original Hebrew language and culture in which the Old Testament was composed:
A relic of polytheism?
It's quite possible that the plural elohim referring to God in the Hebrew of the Old Testament is a relic of polytheism.
Judaism is a monotheistic religion. However, it emerged from a polytheistic culture, and many relics of that polytheistic origin and culture are found throughout the Old Testament. For example, in Deuteronomy 10:17 (and in several other passages) the Lord, God of Israel is called "the God of gods." The word for both "God" and "gods" in these passages is elohim.
However, Judaism, a monotheistic religion, would never have allowed its sacred text to imply that there really was more than one God. So even if the word elohim might have been a relic of polytheism, in reference to God it was not seen as implying that there was more than one god, or (to use the aforementioned anachronistic concept) that there were multiple persons, or personalities, of God.
Plural of majesty
The simplest and most basic explanation the plural form of the Hebrew word for God (elohim), and the occasional use of the plural pronoun "us" in reference to God, is that it is a plural of majesty, otherwise known as "the royal we."
If a king says, "We do hereby decree . . ." no one thinks he is referring to multiple "persons" of himself. It is simply a common way for very powerful people to refer to themselves in a way that sounds more royal and powerful than "I." The royal we has been used in many different cultures over many centuries.
This is a standard response of Jewish scholars to the question of what elohim, and the occasional use of "us" in connection with it, mean in the Hebrew Bible.
Elohim as angels
The Hebrew word elohim is used with many different meanings, not just the meaning of "God." The Gesenius Hebrew lexicon lists nearly a dozen different meanings of the word in various forms.
One of those meanings is "kings." Another is "angels." In other words, elohim, which is related to the Hebrew word el, whose primary meaning is "mighty, powerful," can also refer to powerful beings other than God, such as angels and kings.
The most often quoted example of this meaning is Psalm 8:6, which is translated in the King James Version as:
For thou hast made him a little lower than the angels, and hast
crowned him with glory and honour.
But here it is in the NRSV:
Yet you have made them a little lower than God, and crowned them with
glory and honor.
Why the difference?
Because the original Hebrew word translated "angels" in the KJV and "God" in the NRSV is elohim. The KJV and other traditional translations use "angels" there based on the quote of it in Hebrews 2:7 as:
You have made them for a little while lower than the angels
The Greek word here is definitely "angels," not "God." That's because the author of the Hebrews was quoting from it the early Septuagint Greek translation of the Hebrew Bible, which uses the Greek word for "angels" in translating Psalm 8:6.
Some other examples in the Hebrew Bible where elohim most likely means "angels" or "powerful ones" rather than God are Psalm 82:1, 97:7, 138:1. It is commonly translated "gods" in these passages, but more likely it was originally meant as a poetic way of referring to powerful beings such as angels.
This meaning of elohim as angels is why some commentators think of the "us" in Genesis 1:26 and 3:22 as meaning that God is referring to the "angels who do his bidding" (see Psalm 103:20).
In other words, in saying "us" in these two passages, God may be referring himself together with his "agents," the angels, who carry out his commands relating to humans on earth.