In Mechanics we define pressure as "the amount of force acting per unit area". It appears naturally in fluid mechanics where we consider a volume of fluid $W$ contained in a region filled with fluid and we ask about the force due to the rest of the fluid on $W$ accross its boundary $\partial W$.
Now, in Thermodynamics, pressure is defined by
$$P = -\dfrac{\partial U}{\partial V}$$
That is the rate of change of internal energy with respect to the volume. Now why is that? I mean, what is the motivation to define pressure in that way in Thermodynamics? If it's still force per unit area, what force per area are we talking about here? And where is this force applied?
In fluid mechanics, for instance, pressure is defined pointwise, that is, if $D\subset \mathbb{R}^3$ is the region of the fluid, then pressure is a field $p : D\times \mathbb{R}\to \mathbb{R}$ such that if $S$ is a surface in $D$ with normal $\mathbf {n}$ then the stress force accross $S$ at $a\in S$ is $p(a, t)\mathbf{n}(a)$.
So, $p$ is a force per area which we know where it acts and by whom it is applied. In Thermodynamics, however, it seems the pressure is the same for the entire system. So if we pick a thermodynamic system, pressure is a characteristic of the state of the entire system.
This confuses me, because I can't see what this thermodynamic pressure really is and why it is defined as the partial derivative of internal energy with respect to volume.