Unlike many vaccines, which contain either killed viruses/bacteria or less dangerous versions of living bacteria, Gardasil, the cervical cancer vaccine, does not contain any of the HPV virus. There is no viral DNA, and it is the DNA that allows a virus to replicate and be infectious.
Instead, the HPV vaccine is made up of virus-like particles (VLPs). If you think of a virus as a very nasty M&M, VLPS are, essentially, the candy coating with no chocolate inside. The proteins that form the viral coat are grown in a bacterium and then purified and self-assembled. It looks like the HPV virus but it is, literally, a shell of its former self.
How does this give you immunity to the virus? Vaccines work by stimulating your immune system to make antibodies that will protect you against an invading pathogen. In order to do this, your body needs to know what the pathogen, in this case the HPV virus, looks like. Normally, it requires an infection to get your body riled up enough to produce antibodies, but vaccines use substances called adjuvants to tell your immune system to get things going.
With Gardasil, your body is stimulated by the adjuvant to react to something that looks like the HPV virus, but isn't. It's like telling someone to recognize you by the red carnation on your coat. All they're looking for is the red carnation, not who is wearing it. They'll remember the carnation the next time they see it - even if someone else is inside.
In other words, since Gardasil doesn't contain any HPV DNA, it can not give you HPV. It is the HPV virus itself that causes cervical cancer. Therefore taking Gardasil is no more likely to give you cancer than taking any other vaccine.