It’s all because of the surface tension of the carbonated liquid and the energy contained in it. This effectively keeps some of the gas bubbles in the carbonated liquid.
So what’s surface tension? Well, under normal circumstances, these carbonated liquids resist the expansion of bubbles. This happens because all water molecules attract each other strongly which results in them forming a tight mesh around each of the gas bubbles. Energy is required to push these water molecules away from each other to either allow a new bubble to form or to further expand an existing bubble. This energy requirement to separate the liquid molecules from each other during the bubble formation is what is called surface tension.
When a tiny bubble begins in a carbonated liquid, the energy needed per molecule of carbon dioxide in the bubble is comparatively large. This means that it’s pretty difficult to get started. However, once that tiny bubble is formed, a much smaller amount of energy is needed to expand the bubble. When you shake a bottle or can of carbonated liquid, lots of small bubbles are formed, which join together to form larger bubbles. These energy laden large bubbles escape very quickly from the carbonated liquid causing lots of fizz.
A carefully handled carbonated liquid in a still state in a wide-mouthed container is able to retain some of the gas for many hours as bubbles are formed at a very slow rate, have little energy to escape and held back by the mesh of molecules. Obviously, most of the get through in time causing the carbonated liquid to eventually go “flat”.
For more information on this Google “Mentos and Diet Coke” which shows the fun side of this phenomenon.