An obsession is an unwanted, negative thought that gets "stuck" in your mind.
The thought can be totally illogical, and the person recognises the irrationality and improbability of the negative thought.
For example, you might think that your child will be killed if you don't keep your house clean and free of germs. This belief creates anxiety (pounding heart, short and shallow breathing, tightening of the neck and back muscles so severe that i causes physical pain, and perhaps dry mouth and the feeling that you will vomit).
Compulsions are usually behaviours and are designed to avert the anticipated bad event.
For example, you keep your house immaculate so that your child will not be killed. As you clean your house, more thoroughly than any surgeon would scrub their hands and arms before an operation, you find your anxiety associated with the obsession decreasing.
The compulsive behaviour (house cleaning) thus decreases the anxiety associated with the obsession (the thought that your child will die), and each time this occurs (you engage in the compulsion to reduce the obsession) the link between the two becomes stronger. You feel more compulsive urges even though your intent is to decrease the obsession. Both increase!