HPV can be transmitted sexually and it is the most common way, but it's definitely not the only way. Once you've contracted one of the variants the vaccine prevents it is too late for that one so that's why they want to do it as early as possible. The most common vaccine Gardasil 9 protects against 9 variants. Of course it's best to take advantage of the best protection it can offer, so why not do it early?
Also, it takes 3 jabs and about 8 months (increasing intervals) so it's important to do it early for that reason too.