"何個(なんこ)~" - means "How many ~" if it is phrased as a question. However, if you add か to the interrogative phrase 何個 then it becomes "some ~" and the phrase 何個か is treated as an adjective that can only be connected to a noun with の. So, the full phrase is saying "Some balls are yellow."
This is the impression I get at least if I am remembering my Japanese grammar correctly. The same can be done with any counting word.
何枚かの紙 Some sheets of paper
何本かの鉛筆 Some pencils
I hope this explanation is clear. If you need clarification, let me know.