The first two stanzas of "The Walrus and the Carpenter" set up the absurd, self-contradictory "nonsense" world of the poem. While it seems the speaker is narrating a normal scene—the sun "shining on the sea, / Shining with all his might"—it quickly becomes apparent that something's not right. It is, in fact, the middle of the night!
The diacope of the word "shining" emphasizes the force of the sun's rays, which certainly shouldn't be out at this hour. Nevertheless, out they are, making the "billows smooth and bright." In other words, the sun's light illuminates the swirling water below. The bold /b/ alliteration here ("billows"/"bright") evoke's the sun's eagerness to shine.
Note that the poem personifies both the sun and the moon here: the speaker refers to them using male and female pronouns, respectively. The moon even has an opinion about what's happening, remarking that "It's very rude of him" (him being, of course, the sun) "To come and spoil the fun!" She's "shining sulkily," pouting as her light pours down, miffed that the sun is hanging out where he has "no business" being.
The sun's decision to trespass into the moon's territory also sets the thematic tone for the rest of the poem, which, despite its silliness, makes some real points about hierarchy and power. Even though it's not fair to the moon, the sun follows his desires with no regard for her feelings; later in the poem, the Walrus and the Carpenter will mirror his actions in their treatment of the vulnerable Oysters.
These stanzas establish the poem's form: "The Walrus and the Carpenter" consists of sestets, or six-line stanzas, in which the second, fourth, and sixth lines rhyme. This creates the rhyme scheme ABCBDB. The poem also alternates between lines of iambic tetrameter and iambic trimeter. Odd-numbered lines include four iambs (poetic feet with a da-DUM rhythm), while even-numbered lines have just three iambs:
The sun | was shi- | ning on | the sea,
Shining | with all | his might:
He did | his ve- | ry best | to make
The bil- | lows smooth | and bright—
The meter is steady but not so perfect that it feels rigid. Notice, for example, the trochee that starts line 2: "Shining." Overall, the poem's predictable, bouncy meter and rhyme scheme add to its light-hearted tone.