I maybe completely wrong and I'm sure I will be corrected if so but my understanding is there are two types of HPV, the one that causes warts and the one that can cause cervical cancer. Which ever one you have stays in your system. You can't re catch it if you already have it but you can, in theory, catch the type you haven't already got.
Your immune system clears it so it doesn't stay forever. if you are re-infected by a new partner then it's there again until your immune system deals with it. Various factors can make it harder to clear ( diet, smoking etc) .