An analogy is a comparison between two ideas that are very different from each other. The analogy usually tries to use one of the elements (the one which is more familiar) to explain the other one. This is done through the use of metaphors and similes.
In "The Road Not Taken," the author compares life to a road. Therefore, the road is being used to explain the concept of life, which is a more complex one. On the other hand, "O Captain! My Captain!" uses an analogy in order to compare Abraham Lincoln to a ship captain, leading his vessel and his crew (the nation) to a safer port.
These analogies have become famous for several reasons. First, the analogies are accurate, and this allows the author to use extensive metaphors in complex ways. Second, the analogies are very visual, and the author's use of imagery allows the reader to form a clear picture in his mind. Finally, the authors talk about topics that are relevant for their audiences in accessible ways.