So a given system of $N$ particles has $3N$ position coordinates and $3N$ momentum components for each of the particles, and so the "true" system lives in a $6N$-dimensional space that we call "phase space."
We can't in general observe any of those individually, we only care about these big numbers: like how many total particles are there, how much volume is the box that they're stuck in, how much energy do they have. Some given value of those parameters needs to correspond to a "volume of phase space," containing all the microscopic states which would be compatible with the macroscopic parameters that we care about. Another important idea then is "entropy", which is an additive measure of these phase space volumes. Entropy is a function of the observable parameters of the system.
Now you can basically imagine that our uncertainties multiply and so a system in a sealed box with constant volume, number of particles, and energy, will basically just "wander" among the possible microscopic states randomly. If it does, then our best guess is "the system will be in the state of highest entropy," just because it has the biggest phase-space volume and the particle takes a random point in the phase space.
Now imagine that you have one big box made of two littler boxes which are sharing energy. The total entropy is, as we said, additive, so it is $S_1 + S_2.$ If we transfer a chunk of energy $\delta E$ from sub-box 2 to sub-box 1, it will increase the entropy only if:
$$\delta S = \frac{\partial S_1}{\partial U}~\delta E + \frac{\partial S_2}{\partial U}(-\delta E) > 0.$$ Since energy spontaneously goes from hotter things to colder things, this gives us an immediate definition of $\frac{\partial S}{\partial U}$ as some sort of "coldness" of an object, where $S$ is this entropy function that calculates the phase space volume, and $U$ is the parameter of the internal energy to a box.
You might object that temperature could include parameters from various other sources, and this is potentially true: but we haven't needed any yet. We just define $T^{-1} = \frac{\partial S}{\partial U}$ and that is the "thermodynamic temperature." Two systems which share energy see energy flow spontaneously from higher temperature to lower temperature until both temperatures are the same, and this is simply due to our uncertainty about the microscopic state of the universe growing and multiplying.
Now do the same thing for volume. A box of total volume $V$ is made up of two sub-boxes with a movable partition which shares volume between the two: The exact same argument suggests that $\partial S / \partial V$ must be some sort of "wanting-more-volume-ness" that must become equal when you bring the two boxes into contact. We would say, the two boxes share volume until they come to the same pressure. In this case we generally normalize by temperature again and instead of inverting the relation with the $\bullet\mapsto\bullet^{-1}$ trick we just use a minus sign, $-P = T \frac{\partial S}{\partial V}.$
So there you have your answer. You can either view pressure as the force on the walls from the inside out, or from the outside in: these are the same precisely because two systems which are allowed to share volume (the walls are allowed to move) will come to the same pressure. If you have a solid box whose walls are not allowed to move, then obviously the pressure outside no longer has anything to do with what's happening inside and the relevant pressure is the one inside. But when you hear that an object is under a fixed pressure, it's saying that the object is sharing its volume with a very large reservoir of volume that therefore maintains a more-or-less constant pressure as the object in question expands or contracts.