Why is it natural to define a prime as $p|ab$ implies $p|a$ or $p|b$?

Good question!

There are probably several possible answers to this question, but here is my perspective.

Reason 1: Ring Theoretic

Let $R$ be a commutative ring. Let $f\in R$, then consider $fR=\{af : a\in R\}$. You can check that this is an ideal of $R$, and it is also often denoted by simply $(f)$ (meaning the ideal of $R$ generated by $f$).

Now we can ask the question

When is $R/fR$ a domain?

It turns out the answer is:

Precisely when $f$ is prime. (Or $f=0$)

Proof:

If $p$ is prime, then if $$ab\equiv 0 \pmod{pR},$$ by definition this means $p\mid ab$, which since $p$ is prime implies that $p\mid a$ or $p\mid b$. However this in turn means $$a\equiv 0\!\!\pmod{pR}\quad\text{or}\quad b\equiv 0\!\!\pmod{pR},$$ which is what it means for $R/pR$ to be a domain.

Conversely, if $R/pR$ is a domain, then if $p\mid ab$, $ab\equiv 0 \pmod{pR}$, so either $a\equiv 0 \pmod{pR}$ or $b\equiv 0 \pmod{pR}$, which means either $p\mid a$ or $p\mid b$. Hence $p$ is prime. $\blacksquare$

Note:

As rschwieb points out in the comments, I should have been a bit more careful when originally writing this. We usually exclude $0$ from the definition of prime (as you've done above). However $R/0R=R/0=R$ is certainly a domain. I suspect that the reason for excluding $0$ is a function of the other motivations for this definition discussed below. Since if we allow $0$ to be prime, then it complicates the statment of unique prime factorization, since after all, $0=0\cdot 3^2=0\cdot 101=0\cdot (-17)$, so how can $0$ have a unique prime factorization?

For more on this and a different perspective, I recommend rschwieb's excellent answer here (same link as in the comments).

Reason 2: Number Theoretic (kind of)

The other way we come up with this naturally is that it is the condition we need to hold in order to get unique factorizations.

I.e., suppose we have two factorizations of an element $x\in R$ into irreducibles $$x = \prod_i p_i = \prod_j q_j,$$ with $p_i,q_j\in R$ irreducibles, then when are we guaranteed that some $p_i$ occurring in the first factorization appears somewhere on the left hand side (or an associate of $p_i$, i.e. a unit times $p_i$, since for example in the integers we could have $9=3\cdot 3 = (-3)\cdot (-3)$)?

Well, we need to have $p_i$ divide one of the $q_j$ (for then they are associates, since $p_i$ and $q_j$ are irreducibles).

The condition that for all multiples $x$ of $p_i$, $p_i$ divides some $q_j$ for any factorization $x=\prod_j q_j$ of $x$ into irreducibles is equivalent to $p_i$ being prime (for a Noetherian ring, so that we are guaranteed to have factorizations into irreducibles, otherwise bad things could happen).

Proof:

A note on notation: I'll replace $p_i$ with $p$.

Suppose $p$ is prime, and $p\mid x$, and $\prod_j q_j$ is a factorization of $x$ into irreducibles, then we induct on the length of the factorization. If $x=q_1$ is irreducible, then $p\mid q_1$ by definition, and we are done. Otherwise, since $p\mid (q_1\cdots q_{n-1})q_n$, then by primality of $p$, either $p\mid q_1\cdots q_{n-1}$, in which case $p\mid q_j$ for some $j$ by the inductive hypothesis, or $p\mid q_n$, and we are done.

Conversely, if $p$ has the property discussed above, then if $p\mid ab$ for some $a$ and $b$, then let $a=\prod_i\alpha_i$ and $b=\prod_j\beta_j$ be factorizations of $a$ and $b$ into irreducibles (since $R$ is Noetherian. If you aren't familiar with Noetherianness yet, then just take the existence of factorizations into irreducibles as a black box for now). Then $p\mid x ab= \prod_i \alpha_i \prod_j \beta_j$, so by the property we're assuming $p$ has, either $p\mid \alpha_i$ for some $i$, or $p\mid \beta_j$ for some $j$, and thus either $p\mid a$ or $p\mid b$. Hence $p$ is prime.

Reason 3: (Actually a consequence of reason 2)

There is a theorem, which is relevant here.

A Noetherian domain $R$ is a UFD if and only if every irreducible is prime.