I am reading A First Course in Differential Equations with Modeling Applications (10th Edition) and here is a definition:
Any function $\phi$, defined on an interval $I$ and possessing at least $n$ derivatives that are continuous on $I$, which when substituted into an $n$th-order ordinary differential equation reduces the equation to the identity, is said to be a solution of the equation on the interval.
I am wondering why the condition "on an interval $I$" is important (this has been emphasized in other places of the book). For example, why it is not okay to say that $$y=x^{-1}, x\neq 0$$ is a solution to the differential equation $y'=-x^{-2}$?
One could talk about $y=1/x$ being a solution of $y'=-y^2$ on $(-\infty,0)\cup (0,\infty)$; there is no problem with generalizing the concept of a solution in such a way.
It's just not a useful generalization. What we want to eventually get is not a solution, but the solution: the one and only one that satisfies certain initial (or boundary) conditions. After all, we are trying to model something with an equation, our model should make some definite predictions. You probably would not be happy with a weather forecast of the form
We use initial conditions to pin down a solution. In the above example, requiring, say, $y(1)=2$ determines the solution as $1+1/x$ on $(0,\infty)$ but it could still be any $C+1/x$ to the left. The disjointness of two intervals means the effect of initial condition does not propagate from one to another. One would need another initial condition for the negative part... at which point we either have to change the statements of all theorems that have to do with uniqueness of solutions, or realize that those disjoint intervals should be considered separately.
Related: Why is it differential equations exist on an interval instead of a domain?