Technically, you need to have skin to skin contact to infect the skin although that may not always be the rule. How you got them on your anus, only you could answer. Perhaps some gal fingered you??? Don't worry too much about this though. Just go through all the steps to get rid of them and perhaps have some follow-up's in the future to make sure they don't come back. Just remember, even though the warts may be gone, some parts of your skin may still contain the virus and thus you could spread it to your partner. Just something to be aware of. Talk to your doctor about it.