The Gemmorah in Sanhedrin 56b learns that Adam was given the 7 Noahide laws from the verse "וַיְצַוי"א עַל־הָאָדָם לֵאמֹר מִכֹּל עֵץ־הַגָּן אָכֹל תֹּאכֵל׃", that comes before the formation of animals and Eve:
"From where are the Noahide mitzvot, derived? Rabbi Yoḥanan says: It is from that which the verse states (Genesis 2:16–17): “And the Lord God commanded the man, saying: Of every tree of the garden you may freely eat; but from the tree of the knowledge of good and evil, you shall not eat from it, for on the day that you eat from it, you shall die” ."
Apparently, Adam was created intelligent enough to understand the laws which include adultery and bestiality (some say also castration) which necessitate the existence of both animals and women.
However, not only was he alone, but he didn't wonder where are all those creatures he was commanded about. God also doesn't show any sign of puzzlement or confusion. He forms those only after realizing that leaving the human by himself is "not good".
How can this story be harmonized?