Compare is used to point out likenesses, similarities and to examine two or more objects to find likenesses or differences.
Usage Note
Compare usually takes the preposition to when it refers to the activity of describing the resemblances between unlike things.
He compared her to a summer day.
It takes with when it refers to the act of examining two like things in order to discern their similarities or differences.
The police compared the forged signature with the original.
When compare is used to mean "to liken (one) with another," with is traditionally held to be the correct preposition. That little bauble is not to be compared with (not to) this enormous jewel. But to is frequently used in this context and is not incorrect.
Read more about compared to vs. compared with here.
Contrast always points out differences.
Usage Note
The noun contrast may be followed by between, with, or to.
There is a sharp contrast between his earlier and later works.
In contrast with (or less frequently, to) his early works, the latter plays are dark and forbidding.
When contrast is used as a transitive verb, both with and to may follow, though with is more common.
Most scholars contrast the light comedies of his early career with (or to) the dark comedies that were written late in his life.