Why do books say "of course" it's never that simple, differential equations?
The equation $$M(x,y) dx + N(x,y) dy = 0$$ means the following: that $x$ and $y$ are related in such a way that if we start at any point $(x,y)$, and then make an infinitesimal change $dx$ in $x$, then the corresponding change in $dy$ is such that the above expression equals zero.
It might be easier to understand if you rewrite this as $$M\bigl(x,y(x)\bigr) + N\bigl(x,y(x)\bigr) \dfrac{dy}{dx} = 0.$$ This means that $y$ is a function of $x$, and the derivative $dy/dx$ satisfies the preceding equation. It has the same meaning as the preceding equation with $dx$ and $dy$ separated.
Now suppose that $M(x,y) = \dfrac{\partial f}{\partial x}(x,y)$ and $N(x,y) = \dfrac{\partial f}{\partial y}(x,y).$
Then we may rewrite the preceding equation as $$\frac{\partial f}{\partial x}\bigl(x,y(x)\bigr) + \frac{\partial f}{\partial y}\bigl(x,y(x)\bigr) \frac{dy}{dx} = 0,$$ which by the chain rule is the same as saying that $$\frac{d f\bigl(x,y(x)\bigr)}{d x} = 0,$$ or equivalently, that $f\bigl(x,y(x)\bigr)$ is constant, as $x$ varies.
Your textbook phrases things slightly differently, because it is using the first version of the differential equation: it writes instead $$\frac{\partial f}{\partial x} (x,y) d x + \frac{\partial f}{\partial y}(x,y) dy = 0.$$ Now this is the total change in $f(x,y)$ when $x$ changes by $dx$ and $y$ changes by $dy$.
So what this equation says is that if $x$ and $y$ are related so that the changes $dx$ and $dy$ are related to each other by the original equation, then the quantity $f(x,y)$ will not change as $x$ (and hence $y$) changes.
So it is not asserting that $f(x,y)$ is constant for any values of $x$ and $y$; rather, that $f(x,y)$ is constant as $x$ and $y$ change according to the constraints of the original equation. In short, $$f(x,y) =c$$ is a solution of the differential equation.
[As far as I can tell, the reasoning, such as there is, in the text that follows the "Of course" is completely bogus; it is arguing as if $dx$ and $dy$ are independent quanities. If they were, i.e. if the change in $f(x,y)$ were zero no matter how we varied $x$ and $y$, then indeed $f(x,y)$ would be constant for all values of $x$ and $y$, but then the differential equation wouldn't be very interesting, since $M$ and $N$ themselves would be the zero functions. Rather, the d.e. asserts that the change in $f(x,y)$ is zero if we vary $x$ and $y$ in some related way, and the conclusion one wants to draw is the one I drew above, namely that $f(x,y)$ is constant when $x$ and $y$ vary according to the particular constraint of the d.e.
Let me give an example: we could take $f(x,y) = xy$, just to choose one of the infinitely many different functions $f(x,y)$ of two variables that you could write down.
Then $M = y$ and $N = x$, and the d.e. is $$ y dx + x dy = 0,$$ or, in the second form that I wrote it, $$y + x \frac{dy}{dx} = 0.$$ Now the solutions is given by $x y = c$, i.e. by $$y = \frac{c}{x},$$ for an arbitrary constant $c$. (Check!)
Note that is certainly not true that the partial derivatives of $f$, i.e. $M$ and $N$, vanish identically!
So one (slightly sarcastic) answer to the question as to why an author writes "of course" is that this is mathematical shorthand for making an unjustified assertion that is quite possibly wrong!]
The book is being lazy with this derivation, and the "of course" is meant as a bluff to make you not think very hard about why the next step is true. It should read:
Then if there is some function $f(x,y)$ such that $$ \frac{\partial f}{\partial x} = M\qquad\text{and}\qquad\frac{\partial f}{\partial y} = N\text{,} $$ then we can rewrite the differential equation as $$ \frac{\partial f}{\partial x}dx \,+\, \frac{\partial f}{\partial y}dy \;=\; 0. $$ From the multivariable chain rule, we can recognize the left side of the equation as the total differential $df$ of the function $f$. In particular, the equation states that $df = 0$, i.e. that $f$ is identically constant. In other words, $$ f(x,y) \;\equiv\; c. $$