About the pressure of a confined gas According to fluid mechanics, we have Pascal's principle $P_2 = P_1 + \rho gh$. So, the pressure of a confined gas is different depending on the depth. 
However, in thermodynamics, we have another formula $PV = nRT$. They use a confined gas to use this formula. Here, what is the $P$? Does $P$ refer to the pressure exerted onto the piston by a gas or the average pressure? 
Or, since the density $\rho$ of the confined gas is so low that we can neglect the pressure difference? 
Also, on the microscopic level, they say the reason why the (ideal) gas exerts on the walls is that every molecule collides with the walls. In this case, how can we explain the difference of the pressure depending on the depth of the wall?
 A: The atmospheric pressure drops about 11.3 pascals per meter the first 1000 meters above sea level. The pressure at sea level is 101,325 pascals. The fractional difference between the bottom and top of a cubic meter of air is therefore only 0.00011152 
Hope this helps 
A: The ideal gas law assumes constant pressure and temperature throughout the volume of the gas. In case these quantities were vary in the volume, you can use a local form of the law, for instance: $$P=\rho \dfrac{R}{M}T$$
where $P$, $\rho$ and $T$ are the local pressure, density and temperature, respectively, and $M$ is the molar mass of the gas.
As you said, variation of a gas pressure with depth is usually neglected due to the low density of gases, unless for very large values of $h$, like the ones encountered in atmospheric fluid dynamics.
On the microscopic scale: In statistical mechanics, the average kinetic energy of gas molecules depends only on absolute temperature, thus, molecules will have the same energy anywhere in the container if temperature is uniform. However, the gas density is higher at the bottom of the container, and there will be more collisions per unit area per unit time, which translates to a higher pressure. 
