A comparison involves finding a common element between the two texts or other works involved. Sometimes this is a theme. Sometimes there is a plot similarity. Sometimes two texts will use symbols in a similar way. Two advertisements might be advertising similar products or using a similar strategy to sell their goods or services. Two movies could be about super heroes. The question you must always ask is what the two works have in common.
One example that comes to mind is a comparison between Huckleberry Finn and The Secret Life of Bees. In both stories, there is a young person and an older person, both of the same race, going on a journey toward freedom. In both, racial tension is present. Both are also what we call "coming of age" stories. Both make skillful use of water as symbolism, in Huckleberry Finn, using the Mississippi River, and in The Secret Life of Bees, having the characters cross a creek, having a water battle act as a symbol of reconciliation, and having one character drown. These are all details that could be discussed in an essay comparing the two books.
Learning is about making connections. When you are asked to make comparisons, you are training your mind to see the connections, which is a valuable skill throughout life.
Writing a good comparison and contrast essay requires a clear focus on some one aspect of the two works you intend to compare. Ideally, you should focus on something which is a significant aspect of both works. Comparing the number of time both works use the word "the" is unlikely to be of interest to readers of your essay inless there is something extremely signifcant about the manner in which articles are used in both works (e.g. if one work used no definite articles at all).
First decide whether your focus will be the form or the content of the works. If you choose form, you could compare point of view, uses of direct vs, indirect discourse, chronological structure, sentence style, etc. If you focus on content, look at a single major theme, or the authors' attitudes towards some issue.
Make sure that everything in your essay clearly supports the main focus of your essay. In order to cover details in depth without writing an entire book, you need to omit anything which does not directly support your main thesis.