Here's a scenario I want to avoid: you're starting a new campaign and TWO players want to both play Wizards. "Hey, Bob, let's make sure we don't take any of the same spells...ever...because we can always just copy from each other."
Assuming these wizards have been watching each other’s backs in life and death situations for a level or two, why *wouldn’t* they do exactly that? I would be weird not to. The rules haven’t discouraged PCs trading spells since AD&D, and for good reason: because wizards are supposed to be able to learn spells. It is a benefit to the party overall. And it isn’t free (might be nice if the party split the cost with the wizard in fact).
With your typical NPCs it’s a completely different story. Very few wizards would let you borrow their sole spellbook. Something might happen to it. I don’t let people borrow my computer or car in general. Now if I trusted both their motive and their competence, *and* knew they could easily replace it if they broke it, then that would be a different story. But if you are borrowing a spellbook you almost certainly can’t easily replace it if you lose/break it, or you wouldn’t be borrowing one in the first place because of how the mechanics work.
So in order to find someone who lets you copy from their spellbook, you need someone who has a spare spellbook for that purpose. And ideally, it’s their third book (after their backup copy). So they have money. They also want to protect their investment, so either some sort of security deposit is involved, or you copy in their own place, under supervision. Preferably both. At this point, they are running a small business. They might as well also make scrolls and sell them. Depending on what scroll pricing rules you use (I don’t recommend Xanathar’s, because high level scrolls are more expensive to make than powerful permanent items), they could figure out how to price scrolls versus copy privileges for their convenience and profit. (I actually worked up some pricing schemes for this stuff myself to encourage certain types of NPC behavior.)
I would expect mage guilds probably allow copying privileges for a relatively low price for members, and not at all for non-members, or at a high price and restricted to common spells.
The old “no wizard is going to teach someone a spell that can be used against them!” line has always triggered my inconsistency sensor. Sure, if you are playing an extremely low magic game, then yeah, maybe fireball and dispel magic are hard to come by. But if you are even playing a low-moderate magic game, I expect the old standby spells are going to be available to people who are already wizards and probably know where to find more wizards, even if there are relatively few wizards in the world population. It’s only the rare or personal spells you might (or might not) jealously guard.
So basically, unless someone is running a really low magic campaign, my recommendations are:
1) Let PCs copy spells from each other. They are watching each other’s backs and sleeping around the same campfire. It makes sense in world, and it doesn’t break anything.
2) Make NPCs cautious with their spellbooks. Very close NPCs friends might let them copy under the right circumstances, but make sure it would make sense to the NPC.
3) Guilds or shopkeepers might have a standard rate for either copying spells, buying scrolls, or both, and would likely allow any common spells, because you can get it from someone else if they don’t let you pay them for it.
4) Getting spellbooks from defeated wizards is part of the game, just like getting magic weapons from defeated warriors who wielded them. Give such books all the standard spells that make sense, whatever other spells you want the wizard to know, and random extra spells to fill out how many you think it should have. Don’t worry—there is almost always going to be significant overlap with what the PC already knows.
5) Don’t worry about how many spells they get. As others have brought up, it’s really the preparation that is the limiting factor. Clerics and druids know every spell on their list and it doesn’t break anything. The frustration of a wizard player not getting to use their class feature enough is a much bigger problem than their character ending up with half as many known spells as a cleric instead of a quarter as many.