An analogy has to with the correspondence and comparability between two things. If we compare or try to find a correspondence between a tragedy and a sonnet, we come to the conclusion that a tragedy is in the drama category, and a sonnet is in the poetry category. The fact that both belong to a certain art category is one thing they have in common. Hence the analogy: tragedy:drama::sonnet:poetry.
Another example would be:
RPG: video games::romantic comedy: movies.
RPG is a video game genre, and romantic comedy is a movie genre.