The most general definition is:
We will say that $a$ divides $b$ if there is $c$ such that $b=ac$.
Here $a,b,c$ are assumed to belong to the same "structure". I deliberately omitted the "$\mathbb{Z}$" symbol, because that definition easily extends to more general structures, for example (commutative) rings. And indeed: everything divides zero (in a general sense), while zero divides only itself. This matches facts about ideals in rings: every ideal contains zero ideal, while zero ideal contains only itself. Ideals and division are closely related.
Your first definition of course excludes "$0|0$" case, because $0$ is not invertible in any (non-trivial) ring. Moreover the "$\frac{b}{a}$" symbol needs to be defined. For integers it is easy: you take a fraction in the ring of rationals $\mathbb{Q}$. We can do similar construction in every integral domain:
If $R$ is an integral domain and $a,b\in R$ then we will say that $a|b$ if $\frac{b}{a}\in R$, where $\frac{b}{a}$ is taken in the field of fractions of $R$.
And then these two definitions become equivalent, except for $a=0$ case. But only over integral domains. Definition 2 however applies to a wider range of rings. And thus is more widely used.
Over rings that are not integral domains, first definition doesn't even make sense. What does it mean to take fraction $\frac{b}{a}$? Those rings cannot be embedded into any field, and therefore taking a fraction is meaningless. Moreover if $a$ is a zero divisor (in a more narrow sense, i.e. $0=ac$ for some non-zero $c$), then $a$ is not invertible in any ring containing $R$ (in fact these two properties are equivalent). While being a "zero divisor" itself already says that we need a different form of division applicable here. Namely: the second definition.