I'm surprised how many people have no clue on the fundamental basics of this manga.
Affinities make it easier to learn/master the jutsu of that element, you are not limited to what your affinity is. This has been known ever since Kakashi's talk on nature transformation back when Naruto was learning Rasenshuriken, and it was stated that most ninja master two transformations by the time they reach Jonin. This is why Shikamaru told them to use weak, simple Earth Style that would not require practice.
Honestly, don't scream plot hole over your ignorance.
"Because of the difficulty of mastering a nature and the time required to learn it, it is almost impossible for any one person to master all five natures through natural methods. However, those who possess the Rinnegan or Bashōsen can use all five elements, while Kakuzu got them by stealing other people's hearts."