Hormones used in the pill are mostly a synthetic form of the natural hormones progestin and estrogen. Some contain only a progestin, e.g. progestin-only pill, others a combination of progestin and estrogen, e.g. the so-called combined pill.
The combined pill mimics a pregnancy to your body, although you are not pregnant, what prevents you from ovulation. It also thickens the mucus in the cervix, which makes it difficult for sperm to get through.
The progestin only pill works by thickening the mucus at the entrance to the womb. In some women it may also prevent ovulation.