There is a third way. Evaluate and reward people for their individual performance, but
don't make people compete by limiting the prize pool. That is, everyone who reaches certain performance level get a fixed bonus, independent of how many others also receive it. This way, no one stands to gain anything by witholding knowledge, and everyone has an incentive to help everyone else because they can except to be helped in need as well. You also somewhat avoid the free rider problem, because people won't keep helping those who are clearly just lazy.
Anecdote time! When I was a student, performance scolarships at my faculty were distributed this way. There were set thresholds, and if your grade average from the previous year was above a given threshold, you got +X money in scolarship. We were all extremely cooperative. People helped each other all the time, we pooled notes, scans, bootleg textbook pdfs, previous year's exam questions, we passed this knowledge down to younger students, who in turn passed them further after adding more materials of their own. We'd happily help each other get better grades.
You bet there was a lot of us on those scolarships. And people who came from the outside were extremely surprised about how friendly and helpful everyone is.
After I left, my faculty was forced to make scolarships work the way they work at every other faculty/university - i.e. make only top X% of students eglible for rewards. This instantly killed teamwork dead. I know few people who are still studying and they say there's a clear and visible difference now. People no longer share things. They don't care about recording exam questions for others, they don't coordinate the whole year to win something. Students stick to small groups and are antagonistic to others. If they help at all, they do it to the degree it doesn't endanger their own chance for scolarships.
Incentives matter. Also greed/stupid costs savings on the part of people setting up incentive structures matter too.