Counting has been in observed in almost every culture across the world. I think it developed because it proved to be so useful for a range of tasks. I am wondering what the earliest use cases for it was though, I imagine it would be recording food stock / weapons in inventory to trade or population. But these are just guesses, I have no idea. All sources I have observed converge to the consensus that tally marking is the oldest known form, but don't go into much detail about what was being counted at that time, and these sources are all free online articles, so not very good sources (not experienced in research).
If it's not possible to give a concrete answer due to variability / lack of knowledge, any historical analysis would be appreciated, thank you.