The pressure in an ideal gas is only due to collisions with the vessel's walls, collisions between molecules do not contribute. This can be shown by considering general forces on a molecule using Newton's second law of motion. If the force on a molecule is $f_x,f_y,f_z$ in directions $x,y,z$ where
$$\displaystyle f_x=m\frac{d^2x}{dt^2}$$
and similarly for the $y$ and $z$ directions. The energy is found by multiplying by $x,y,z$ as appropriate (because energy is force times distance), giving
$$\displaystyle xf_x+yf_y+zf_z=m\left(x\frac{d^2x}{dt^2}+y\frac{d^2y}{dt^2}+z\frac{d^2z}{dt^2} \right)$$
Now we need to manipulate this equation using a 'trick'
$$\displaystyle \frac{d}{dt}\left(x\frac{dx}{dt}\right)=x\frac{d^2x}{dt^2}+\left(\frac{dx}{dt}\right)^2$$
and similarly for $y,z$ and so obtain an expression for the second derivative. Substituting for this gives
$$\displaystyle xf_x+yf_y+zf_z=m\frac{d}{dt}\left(x\frac{dx}{dt}+y\frac{dy}{dt}+z\frac{dz}{dt}\right)-m\left(\left(\frac{dx}{dt}\right)^2+\left(\frac{dy}{dt}\right)^2+\left(\frac{dz}{dt}\right)^2\right)$$
the right-hand most term is just the velocity $v$ squared multiplied by the mass $m$ and is therefore $mv^2$ is twice the energy of the molecule giving
$$\displaystyle xf_x+yf_y+zf_z=m\frac{d}{dt}\left(x\frac{dx}{dt}+y\frac{dy}{dt}+z\frac{dz}{dt}\right)-mv^2$$
The remaining derivate is $\displaystyle x\frac{dx}{dt}=\frac{1}{2}\frac{dx^2}{dt}$ producing
$$\displaystyle xf_x+yf_y+zf_z=\frac{m}{2}\frac{d}{dt}\left(\frac{d}{dt}(x^2+y^2+z^2)\right)-mv^2$$
So far this applies only to a single molecule. Over all molecules while the value of $\displaystyle \frac{d}{dt}(x^2+y^2+z^2)$ must fluctuate in time for any given molecule, overall all these values must average to zero, because if this were not so the gas would be expanding or contractions as time progressed.
The expression becomes, after rearranging and summing over all molecules,
$$\displaystyle \frac{1}{2}\sum mv^2=-\frac{1}{2}\sum (xf_x+yf_y+zf_z)$$
The term of the left is the total kinetic energy which from laws of motion is $3k_BT/2$ per molecule with $k_B$ being the Boltzmann constant therefore
$$\displaystyle Nk_BT =-\frac{1}{3}\sum (xf_x+yf_y+zf_z)$$
for $N$ molecules. (The term on the right is sometimes called the 'virial of Clausius').
The right hand side of this equation needs to be calculated. To do this we first find the force on one wall, say wall $xy$, and this force has the value $xyp$ where $p$ is the pressure ($\equiv$ force/area) and $xy$ is the area. The total force the wall exerts is therefore $-xyp$, and similarly for the other walls, $xz$ etc. The average distance of a molecule from a wall in the $x$ direction is $x/2$ so the energy $xf_x$ has a value $-xyzp/2$, thus over all six walls is $-3pV$ where $V=xyz$. Thus over all walls this is also the value of $\sum (xf_x+yf_y+zf_z)$.
The ideal Gas Law $pV=Nk_BT$ is thereby produced and so in the absence of intermolecular interactions all the pressure is caused by collisions with the wall. In other words, the effect of all the forces the molecules experience, but not those caused by intermolecular interaction, is to produce the ideal gas law.
If intermolecular interactions are added then we must add a similar general term term
$$\displaystyle pV=Nk_BT+\frac{1}{3}\sum (xf_x+yf_y+zf_z)$$
where now $xf_x$ etc. now refer only to intermolecular forces. This term can be recast in a form that measures the pair-wise interaction between molecules $\varphi$ at a radial distance $r$ and has the form $-\sum r\frac{d\varphi}{dr}$. This term is the origin of correction terms such as in the van der Waals equation.