Both prepositions, to and with, can be used following compare.
Neither is more correct than the other, but a slight distinction can be made in meaning. (It is very slight, though, so perhaps it's more than enough for you to know that you can use both compare to/with)
To has traditionally been preferred to emphasise similarities between the two elements being compared.
To compare something to something else is to observe or point only to likenesses between them. In other words, you are likening one thing to another, or you are making a comment about their similarities:
He compared their historic win to that of the 1992 Dream Team.
His fight for civil rights is comparable to Dr. Martin Luther King Jr
David Cameron has been compared to William the Conqueror, but not in a good way.
To compare something with something else is to place the items side by side, noting differences and similarities between them.
His house was modest compared with the mansions of other wealthy industrialists.
Kidney transplantation doubles life expectancy compared with dialysis treatment.