Is it as common to say "Why not?" to mean yes when people are asking for your permission; such as, "Can I borrow your pen?" as when replying to an invitation; such as, "Let's go to the movies"? What are the nuances of the first situation?
Why Not doesn't quite mean yes, but I'd say it's a synonym.
In your example:
Could I borrow your pen?
Yes would mean simply Sure, you can have my pen.
Why not means There is no reason why you can't borrow my pen.
I wouldn't say that's it's a super common response to your example question, but you could certainly say it. I think it sounds a bit more natural if you prepend it was Sure or Yea as in Sure, why not or Yea, why not. In this example, it carries the connotation of why are you even asking? or next time don't even ask, just take my pen. If this isn't what you intend to say, then I probably wouldn't use Why Not.
Personally, I would probably say something like "Yes, here you go" if I was trying to be formal and something like "Sure, no problem" or "Sure, no prob" if it was a more casual situation. That doesn't make these "correct" by any means, just what I'd personally say.