It sounds like you are aware of many of the variables involved, so I can skip a lot of descriptions of those factors. There were no true CO2 scrubbers however, those weren't perfected until after the war and the advent of nuclear submarines. As you can imagine there were many submarine classes from multiple countries so capacities and capabilities varied. The "average" U.S. Gato-class submarine could stay down about 48 hours, assuming non-necessary personnel would be ordered to their bunks to reduce activity and slow breathing rates. It was less for most of the German U-boats, especially the most common one, the Type VII. The Type VII was the smallest German U-boat and could normally only stay down about 14 hours. . It was always a race as to what would run out first, the electrical power, or the air. Almost always, it was the air. On the very large Gato class boats, after 24 hours the air would be noticeably bad. After 48 hours, it would be unbearable and you would have to surface.
The World War II submarine that had the longest possible underwater endurance was the German Type 21. It could stay down for up to 75 hours, which gives you a tad over 3 days. However this boat , which only became operational the last year of the war had extremely poor manufacturing quality, and of 118 made, only two made it to sea on patrols before the war ended, and neither sank any ships.
The scenario where a submarine would just sit on the bottom and not move, was rare. This left you with no control of your ship, and subject to tidal rips, currents, and any nets dragged along the bottom, and not too many submarine skippers like that. It also blocks intake and discharge vents which many submarines have along the bottom of the hull. The usual and much more preferred procedure was to creep away at a speed of 2 knots. This then usually got you to a safer place eventually where you could then surface and refresh the air. Another big factor was air conditioning. The U.S. boats had it, and nobody else did. Air conditioning is important not only for crew comfort, but for keeping humidity out of the air. In tropical waters, a submerged submarine without air conditioning would sweat inside - and a lot - and the water droplets would form on everything, including electrical equipment, This moisture would cause shorts and start small fires which consume even more oxygen, so whether you had A/C or not was also a big factor for your endurance time as well, especially in the Pacific. This was less a factor in the north Atlantic with U-boats, as the water temperatures there were colder, but once they started ranging into the Mediterranean and Caribbean, the lack of A/C affected their submerged endurance time too.