Nobody got hurt? You weren't charged with anything? Then, you did FINE. Relax, have a col'-beer, and put it out of your mind.
When you start second-guessing yourself (and PARTICULARLY when OTHER PEOPLE start second-guessing YOU), the tendency is to say "How could you have opened the door to a potential would-be rapist/murderer?!?!" I say, "HOGWASH!!!"
Until this guy started acting weird, you had nothing to fear. Until he got weird, as far as you knew, he was just an ordinary Joe, standing on the stoop, selling magazine subscriptions. You had NO reason to fear interacting with this "ordinary guy" at the time you opened the door.
Once he got "weird," you acted perfectly correctly in arming yourself and asserting your right to be free of this threat. You talked him out of your house without incident, and for that, KUDOS TO YOU!!!
At your friend's house, the guy was a bit more assertive, and you were perfectly within right to exercise your right of self-defense of a third party. You got the guy apprehended, without injury or incident to anyone involved. For that, KUDOS TO YOU!!!
So, basically, KUDOS TO YOU!!!
You did fine.