This is basically a question you could ask on Literature SE, but what it looks like is a literary technique called stream of consciousness.
Wikipedia defines it as
a metaphor describing how thoughts seem to flow through the conscious
mind (i.e. without interruptions). In literature, stream of consciousness writing is a literary device which seeks to portray an individual's point of view by giving the written equivalent of the character's thought processes, either in a loose interior monologue, or in connection to his or her sensory reactions to external occurrences.
This site says:
Melville invents stream of consciousness with Stubb, although James
Joyce and Virginia Woolf will get the credit.
This is connected to the English language first because although it is now a universal literary device, it was coined by English native authors, and second, in the sense of how this fluidity is marked in writing [* additions in square brackets by me]:
To represent the full richness, speed, and subtlety of the mind at work, the writer incorporates snatches of incoherent thought [which looks like the phrases in between the em dashes in your excerpt], ungrammatical constructions [don't sleep of nights looks like one], and free association of ideas, images, and words at the pre-speech level. (Britannica)
The stream of consciousness technique becomes obvious in syntax and grammar:
Stream of consciousness writing does not usually follow ordinary rules
of grammar and syntax (or word order). This is because thoughts are
often not fully formed, or they change course in the middle and become
"run-on sentences," or they are interrupted by another thought [interruptions can be indicated through the punctuation that puzzled you]. So
grammar and syntax can be used to replicate this process in ways that
aren't grammatically or syntactically "correct", but that nonetheless
feel accurate. Additionally,
writers of stream of consciousness often use punctuation in
unconventional ways (using italics, ellipses, dashes, and line breaks
to indicate pauses and shifts in the character's train of thought). (Litcharts.com)
Of course, it takes artistry to use grammatical and syntactical "incorrectness" in a way that "nonetheless feels accurate".