Line breaks certainly count as a type of punctuation, but they count differently in different poems. In some poems, the line breaks are crucial in terms of reading into the meaning, while in others it may be more about rhythm or something else entirely. In Mary Had a Little Lamb, the rhythm is classic ballad meter, a 4-beat/3-beat pattern. 4-beat patterns dominate English lyric and song, and the earliest English verse grew out of 4-beat traditions (Beowulf's alliterative prosody). 4-beat creates a distinct sing-song rhythm that is inescapable. The interesting thing about ballad meter is that it plays off this expectation by leaving the last beat of the sequence silent, making us pause on it before we move on to the next line.
So, getting back to Mary's Lamb, your first iteration is the classic ballad meter form. The first 4-beat line pairs with the second 3-beat line and we pause at the end of the 3-beat line for the silent, unexpressed 4th beat. When you instead stretch this 7-beat pattern out to a single line, you do de-emphasize this pattern, although readers may slip into it intuitively anyway. What I think the second version does is not allow as much for that invisible last beat. If you read the second line, eg, as one line, you don't hear the 4/3 pattern as much.
So I wouldn't say they're different poems in terms of meaning, but I do think they're slightly different rhythmically. A better example of someone who exploited line-breaks and the expectations created by the ballad rhythm to its utmost would be Emily Dickinson. One could cite countless examples, but one of her more playful excursions was in "I like to see it lap the Miles:"There are numerous examples in this one poem, but I'll point out two: the first comes at the end of S1 and the beginning of S2:I like to see it lap the Miles -
And lick the Valleys up -
And stop to feed itself at Tanks -
And then - prodigious step
Around a Pile of Mountains -
And supercilious peer
In Shanties - by the sides of Roads -
And then a Quarry pare
To fit its sides
Complaining all the while
In horrid - hooting stanza -
Then chase itself down Hill -
And neigh like Boanerges -
Then - punctual as a Star
Stop - docile and omnipotent
At its own stable door -
And then - prodigious step
Around a Pile of Mountains -
Instead of ending the sense at L4, as is typical with this meter, Dickinson "steps" the sense all the way over the first stanza and into the second stanza, which mirrors what she's describing about the train "stepping around a pile of mountains". If you change this to:
And then - prodigious step Around a Pile of Mountains
then it loses a lot of its affect. You can see a similar device here:
And then a Quarry pare
To fit its sides
Just like she's describing the train paring a quarry, the first line of S3 is "pared" to only 2 beats ("To fit its sides"). One last example would be:
punctual as a Star
Stop
where it's almost as if "Star" becomes an adjective ("Star stop") to the noun "Stop", rather than being a noun followed by the verb "Stop". It's these kind of playful ambiguities that line-breaks can create that, if you wrote it down as prose, you'd lose. I think writing the above as "punctual as a star, stop" is much less effective than the way Dickinson wrote it.