I can't seem to find a clear, definitive, non-circular answer on this. For centuries and centuries, we've been doing mathematics in one form or another, be it geometry and pictures, or inventing symbols to represent numbers and then manipulating them using rules of arithmetic, but I don't understand where these rules were formalized for so many years.
Only in recent years did we get the Peano axioms for defining what a natural number is, or a real number in terms of Cauchy sequences, or Peano arithmetic, etc.
We even had calculus, power series, etc, before a lot of these things took off.
We didn't seem to have a "proof theory" where we all agreed what constituted a proof or what was considered a correct / incorrect proof.
I don't understand how people defined and used all these terms and techniques before we defined what these things were. Every answer I see on this feels circular to me. Did we just "do the math" without caring too deeply about possible edge cases and issues that arise in certain situations? Were proofs simply an appeal to our senses and whether we found it convincing, as opposed to showing 100% that these things always held?
How exactly did we do mathematics for so long and what necessitated the need to redefine the foundations?