Chakra Nature affinities are hereditary. That is why, as you referred, people from the same village or clan generally possess affinity toward the same nature (Uchiha's have a natural affiliation with the Fire Nature). This means that genetically, the affinity is passed from generation to generation, being the one that you are naturally connected to. Despite this, it may be possible for shinobi to have affinities that are different from the ones possessed by their parents, although I cannot remember any examples.
However, shinobi are not limited to the nature toward which they have a natural affinity. So one can also master other Chakra Natures through practice. Generally, shinobi at Jounin level have mastered more than one Chakra Nature.
Having said that, given the amount of time and practice taken for one to master a Chakra Nature, it is practically impossible to master all five Natures (unless you possess the Rinnegan, the Bashousen, or do it the way Kakuzu did).
You can also check out this question, that though not exactly the same, may answer some doubts you may have.
As for the examples you provide:
- Sasuke has a natural affinity toward Fire Nature (as all Uchiha), and trained in order to master Lightning Nature. However, given how well he masters Lightning Nature, I'd say he may well have had a natural affinity toward it to start with.
- Kakashi's natural affinity is toward Lightning Nature, and he masters other Natures through practice, presumably with the help of the Sharingan (in copying and understanding other shinobi's jutsu).
- Whether Naruto's affinity toward Wind Nature is hereditary or not is unknown, since we do not know what affinities Minato and Kushina were born with (both were proficient in Wind Nature transformation, but also in other Natures: Kushina in Water Nature, and Minato in Fire and Lightning Natures).
- As for the variety of Konoha's shinobi's affinities, check out this comment from Madara.
- As for the case of Mei Terumi, I do not think it is known whether her affinities and Kekkei Genkai were obtained naturally or through practice.