Symbolism, Imagery, Allegory
Although they only appear once in the story, submarines are an early sign that Steinbeck is pretty interested in the Cold War and focused on the anxieties of that time in America.
Steinbeck spots the subs while he's taking a ferry across the Long Island Sound to get on the road in New England, and we quickly learn that he is not a fan:
A lovely sloop stood away from us, her genoa set like a curving scarf, and all the coastal craft trudged up the Sound or wallowed heavily toward New York. Then a submarine slipped to the surface half a mile away, and the day lost part of its brightness. Farther away another dark creature slashed through the water, and another; of course they are based in New London, and this is their home. And perhaps they are keeping the world's peace with this venom. I wish I could like submarines, for then I might find them beautiful, but they are designed for destruction, and while they may explore and chart the sea bottom, and draw new trade lines under the Arctic ice, their main purpose is threat. (2.1.4)
As you can see here, Steinbeck much prefers the "lovely sloop," which is a kind of sailboat, to the submarines, since he can only really associate the latter with warfare. And not just any kind of warfare—after all, boats have been used for war for, uh… a long time. No, in Steinbeck's mind, these subs are associated with nukes.
We learn as much when he strikes up a convo with another passenger on the ferry, who just happens to work on a submarine. Steinbeck's first question to him is "Atomic?," so it seems pretty clear that Steinbeck is concerned about this particular use for subs.
Of course, as the book goes on, we find that Steinbeck is pretty preoccupied with the Cold War and the power of nuclear weapons—and interested in how others felt about these topics. So, the submarines are an early indicator and symbol of that overall preoccupation.