Usually when we consider the pressure exerted by gas, there is nothing to do with the weight of the gas. On the contrary the atmospheric pressure is defined as the weight of the gasses. What is the difference here?
This is actually a pretty interesting question.
For starters, it depends on the system you are analyzing. Atmospheric gasses are basically an open system that stays together due to the force of gravity. All the gas further down is supporting the weight of the above gasses. The force of this weight on top pressurizes all the air based on how much mass is above it. See for example John Rennie's linked possible duplicate to explain how it works on a macroscopic level.
In a closed container, we often don't consider the weight of the gas because the effects of the weight are minimal if the height of the container is not very large. In a very tall container, the pressure would also be affected by the weight. The gas on the bottom would have noticeably higher pressure than the gas above, because the gas on the bottom has to support all the weight of the gas above it.
The existence of the container isn't important, what is important is how tall the container is. If it is tall enough, than the weight of the gas will have a noticeable effect on the pressure distribution. Technically any closed container in gravity will have this; but unless the container is very tall the difference is negligible.
when we say pressure exerted by gas we say about pressure exerted by gas on container due to collision of particles with wall of container when kept in closed container we use PV=nRT to define it here pressure due to weight of air is very small so it is negleted ( it is same case as variation of pressure in sound wave) but atmospheric pressure is due to weight of gas as there presdure due to collision of particle with ground can be negleted due to very small value