Imagine water molecules inside a water pipe is moving due to difference in pressure, this pressure can be due to difference in gravitational potential or external force like somebody squeezing at one end. In the case of a piece of wire, how can the electrons inside knows that there is a voltage potential diff between the 2 ends? Is there such a things as electron pressure but why must it be a closed circuit?
The "electronic pressure" is what causes the voltage.
Imagine an electron in the same way as a water particle.
Put pressure at one end and the water particles are pushed from one side. If they are also pushed from the other side, then they don't move - only if there is a pressure difference do they move.
Similarly, a high electric potential is a point of high "electronic pressure". Specifically, there is a large electric field at that point from which the charges are repelled. If there is an equally high potential at the other end, then the "electronic push" is the same from both sides. The charges will not move. Only if there is a potential difference do they move.
We call such a potential difference: voltage.
Electric potential is given by $\int E \cdot dL$ where E is the electric field and dL is a length of wire. Coulomb's law says the force on a charge Q is $ Q \cdot E$. Therefore, if there is a potential difference between two ends of a wire, $\int E \cdot dL$ must be non-zero and thus E is non-zero. Therefore, the electric field is non-zero and so is the Coulomb force.
A piece of wire "knows" there is a potential difference because the potential difference itself is due to an electric field pointing along the wire's surface. This electric field is what causes charge to flow.
The water analog for electronics is common but falls apart pretty easily because electronics and fluids are two very different things. Some educational resources cling pretty heavily to analogies, but I'd recommend avoiding them and looking at the fundamental physics instead - it'll serve you better in the end. An intro physics book such as this free one (https://openstax.org/details/books/college-physics) might help.