Analysis: What's Up With the Title?
To get the obvious out of the way first, the title—“O Captain! My Captain!”—is indeed the first four words of the poem. More than that, though, you should know is that the title is what’s called an apostrophe (not like the punctuation). An apostrophe is a poetry term for when the speaker calls out to someone (or an idea or an object) who’s not actually there. After the captain dies, the speaker is in the position of making this emotional appeal to a person who can no longer respond to him.
In this apostrophe, the first call to the captain gets the attention of the reader, but the second call of “my captain” suggests a bond between the speaker and captain. That possessive and intimate bond announces a theme that is going to get fleshed out in the rest of this piece. Also, the exclamation points add a note of desperation and excitement (though not the good kind) to the poem that follows. This poem is an urgent appeal, and the title lets us know that right off the bat.