HI @Flute56
I once saw a friend and her mother explaining something important to her 6 year old son. He was playing with a cat, and the cat started pulling away. They told him to watch her behavior, and that by pulling back she was actually telling him she needed some space. They said that since she couldn't talk, she was using non-verbal cues to tell him what she wanted and how she was feeling. They explained that if he would respect her needs and give her space, she would likely come back soon and play some more. Otherwise, she was going to avoid him.
The most important part was next, when they said "Max, people are like this, too. They will often tell you what they need without talking. It's really important that you pay attention to this if you want to have good relationships."
I thought this was genius and wished I had learned it at age 6 instead of age 36. It's something that many people know intuitively, but I had never heard it expressed so well.
I think your neighbor and your friend just have different needs. Your neighbor enjoyed impromptu visits, but your friend is not comfortable with that. It's ok, we all have different needs. But I think you should pay attention to what your friend is telling you. You might even want to say "Sorry I popped in on you the other day. It seemed like it wasn't a good time for a visit. I will always ask before doing that, going forward."
You might be surprised at how much more enjoyable your relationships can be when you give this kind of respect to someone.