This statement - "You need to be uninfected in order to get the HPV" - is untrue.
Both the 1st and 2nd generation HPV vaccines protect against multiple strains of the HPV virus; and neither of them protects against all 150 known strains of the HPV virus.
If you've gotten one strain, it does not mean that you've gotten them all or are disqualified from getting the vaccine.
This is mentioned by the CDC in this page in one of the paragraphs:
HPV Vaccine Information For Young Women
Secondly, when Merck decided to first get indication for Garasil, it decided to only pursue it for 'cancer prevention' as a result of acquiring HPV. The company did not seek indication for prevention of HPV
as an STD, in and of itself. Which is why the vaccine was only recommend for young people. Older people would've missed the cancer boat already in acquiring one form of HPV or another.
However Merck has
now sought and gained indication for prevention of genital warts and lesions,
and cancer prevention, which has broaden the recommendation from just adolescents to both men and women up to the age of 45.
This is mentioned in the revised indications on the FDA's website:
Gardasil 9