I agree with you that most books do not follow a logical path when defining thermodynamics terms. Even great books such as Fermi's and Pauli's.
The first thing you need to define is the concept of thermodynamic variables.
Thermodynamic variables are macroscopic quantities whose values depend
only on the current state of thermodynamic equilibrium of the system.
By thermodynamic equilibrium we mean that those variables do not change with time. Their values on the equilibrium cannot depend on the process by which the system achieved the equilibrium. Example of thermodynamic variables are: Volume, pressure, surface tension, magnetization... The equilibrium values of these quantities define the thermodynamic state of a system.
When a thermodynamic system is not isolated, its thermodynamic variables can change under influence of the surrounding. We say the system and the surrounding are in thermal contact. When the system is not in thermal contact with the surrounding we say the system is adiabatically isolated. We can define that,
Two bodies are in thermal equilibrium when they - in thermal contact
with each other - have constant thermodynamic variables.
Now we are able to define temperature. From a purely thermodynamic point of view this is done through the Zeroth Law. A detailed explanation can be found in this post. Basically,
We say that two bodies have the same temperature if and only if they
are in thermal equilibrium.
Borrowing the mechanical definition of work one can - by way of experiments - observe that the work needed to achieve a given change in the thermodynamic state of an adiabatically isolated system is always the same. It allows us to define this value as an internal energy change,
$$W=-\Delta U.$$
By removing the adiabatic isolation we notice that the equation above is no longer valid and we correct it by adding a new term,
$$\Delta U=Q-W,$$
so
The heat $Q$ is the energy the system exchange with the surrounding in
a form that is not work.
Notice that I have skipped more basic definitions such as thermodynamic system and isolated system but this can be easily and logically defined in this construction.
I don't think you need to overthink this so much. Mechanical equilibrium in this context basically means that from a macroscopic point of view, all forces are balanced; this usually also means that the system's parts are at rest, though a system in uniform motion could be considered in mechanical equilibrium, I guess.
The point that the authors are trying to make is that being in mechanical equilibrium (which remember, for our purposes means all net forces are zero and the system is at rest) doesn't necessarily imply that the pressure must be uniform over all the system.
As an example they tell us to consider a column of water inside some container. The water is subject to gravity, so if every small chunk of water is to be at rest, there must be some force counteracting gravity. And indeed there is; in fluids, internal forces come from pressure gradients. Therefore, if the pressure varies as $p = p_0 - \rho g z$ (where $p_0$ is some constant and $\rho$ the density; this is a well known formula in hydrostatics), then the pressure is higher at the bottom. This means that the internal forces, which are equal to minus the pressure gradient, point upwards and cancel out gravity.
Best Answer
This is a classic conundrum and it is called the "problem of the adiabatic piston". You can find it discussed in books on thermodynamics by Landau & Lifhsitz and by Callen. Another very thorough analysis is by Gruber "Thermodynamics of systems with internal adiabatic constraints: time evolution of the adiabatic piston". (You can find Gruber's article here free http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.55.995 )