Prehistoric people could count abstract quantities, like days and years and this is considered the beginning of mathematics. From the beginning of human society mathematics was used to do calculations, needed for commerce, taxation and construction. Mathematics was also used to predict astronomical events and measure land - that's where the term "geometry" comes from. And first of all mathematics needed writing or any other system to record numbers. There were wide diversity of numeral systems in ancient world - the vety first one was created by Egyptians. Some civilizations were very skilled in mathematics, for example the Indus Valley civilization invented decimal system similar to the modern one and they understood the concept of zero.
Mathematics developed into powerful science since then due to interaction with other sciences, which helped mathematicians to affirm theories and observe differnt processes, that were important for mathematic axioms or definitions.