Why both ideas?
We can address your final question - why did Rashi cite both of these explanations - on a simple, structural level by looking at the Talmud passage Rashi got them from. In Shevu'ot 9a, the Talmud deals with an apparent tension between these two concepts, each of whose transmitters derive them from the same textual point - the fact that this korban chatat, unlike all others, is described by the Torah as "לַיהוָ֑ה" - "for God." The Talmud resolves this tension by concluding that the particular phrasing of this "extra" word is special in two ways, permitting both of these concepts to be derived simultaneously. As the Talmud's conclusion is that both ideas reside in this verse, it makes sense that Rashi echoes that position.
Korban for the moon?
To address your more fundamental question - what's going on with this strange-sounding idea of a sin offering for the moon - we need to delve deeper, with the help of some later commentaries. The Maharal addresses this idea at length in his Gur Aryeh supercommentary on this comment1 of Rashi, and R' Samson Raphael Hirsch explains this idea as well in his commentary on this verse2. They each come at it from different angles, but their explanations complement each other.
The Maharal says that to understand this point in the Talmud, we need to understand that some of the terms used there and in the Torah have different meanings than people typically assign them:
- Kapara here doesn't mean "atonement for wrongdoing," but "removal" or "cleansing." (As seen in Rashi's comment on Genesis 32:21.).
- Korban is not an "offering" or "sacrifice" to appease or pay back, but a "means of getting close." (Note that its root, קרב, means "close.")
- Chatat here doesn't mean "sin" so much as "deficiency." (See Genesis 39:31, where אנכי אחטנה means "I will make good the loss.")
So, chatat here doesn't refer to the moon's sin or, as if it could be said, to God's, but rather, to the moon's diminishment. From the point of view of the moon, it had as much right to being the supreme luminary in the sky as the sun does. However, from the point of view of the natural order, it simply didn't make sense to have two co-equal rulers. As described in a story in the Talmud on Chulin 60b, God therefore demoted the moon to secondary status, and it "took one for the team."
As the moon is diminished (chatat) from its "rightful" status, there is an opportunity to draw closer (korban) to God in an act of cleansing for (kapara) that deficiency. In general, the opportunity to draw closer to God comes specifically when one diminishes one's sense of self rather than puffing it up.3 Also in general, the קרבן חטאת is not "paying back for a sin," but "re-connecting with God in light of the deficiency created by sin."
This monthly chatat is therefore the Jewish nation's way to collectively respond to the moon's relative deficiency by recalling self-diminishment as an opportunity to come closer to God.
R' Hirsch also talks about the korban chatat as a response to a deficiency. He says that one is included in the offerings for each of the holidays to respond to the inadequacy of reality, compared to the lofty ideals of total dedication expressed by the holidays' korbenot 'ola. On Rosh Chodesh, when the theme is renewal after back-sliding, this concept is especially pertinent.
The diminishment of the moon, according to R' Hirsch, is symbolic of the very concept of imperfection in the world. He points out something striking: "Sins which human beings do are after all, in truth, the only bad things in God's world." If there's deficiency, it's thanks to our own choices.
But why, people ask all the time, does God let people make evil choices? Because without the freedom to choose sin or virtue, we'd be animals or angels, but not people, and we would not have our reason for being: to dedicate ourselves to God through free-willed good choices. So, like the moon's dimunition, the presence of evil in the world is a necessary part of the scheme of things, sub-ideal though it might look.
This special korban chatat of Rosh Chodesh, then, is not atoning for any particular sin. It's atoning for the fact that sin has to exist - that the moon can't just light the sky all night like the sun does the day. It's also reframing that apparent negative as a positive, acknowledging the great gift of free will, and dedicating it to God.
R' Hirsch also relates these ideas to the Talmud's first explanation of this korban - that it's for those who became tamei without realizing it and then contaminated the holy places. In general, R' Hirsch sees being tamei as living under the illusion that physical forces are all there is, with no room for free will.4 Those contemplated by this korban are in particular danger, in that they are trapped in that illusion without even knowing it. Along comes this general chatat each month to jerk us all out of our unconscious spiritual depression and restore our sense of free will.
R' Hirsch concludes that the two ideas in the Talmud are really two sides of the same coin - dealing with the fact that we are necessarily imperfect and subject to physical forces by bringing us back to realizing the sublime free will that our imperfections enable.
I'm not sure how literally we're supposed to take the Maharal's understanding of the moon's deficiency and our cleansing for it, but the symbolic point is at least also there: When we contemplate our own limitations, we are at the point where we have the best opportunity to draw closer to God. It seems to me that this concept fits well with R' Hirsch's idea of the chatat - turning contemplation of our own [potential for] evil deeds into a celebration and rededication of our free will. For both of them, we bring the special Rosh Chodesh chatat to come closer to God over the very concept of deficiency, which the poor darkened moon, perforce embodies.
1. Pertinent points are summarized in English in this torah.org lesson by R' Yitzchok Adlerstein.
2. This link is to AlHatorah's online presentation of a Hebrew translation of this commentary. English translations are available in book form.
3. For an additional moon-related image to support this idea, I suggest watching this video about the journey that Israel's Beresheet spacecraft will take (starting in three days!) to the moon. When the craft falls the lowest in its orbit, that's the best time to make a push to improve and then go even higher.
4. I discussed this concept with respect to contact with death and with respect to childbirth in previous answers.