A lack of oxygen (hypoxia) can cause death to your brain cells, which can lead to the death of the entire human within 4 minutes (though the exact amount of time varies).
Severe hypoxia will cause apoptosis (cellular suicide) but the precise trigger is more complicated than just "lack of oxygen triggers hypoxia". Calcium overload, increased oxygen free radicals, increased expression of a hypoxia-inducible factor (HIF), and other things are blamed for hypoxia-related apoptosis. This answer would get too long if I tried to explain every mechanism leading to hypoxia-related apoptosis, but I think it would be valuable to explain at least one of them, so you can see more clearly how lack of oxygen causes death, so I will do that for HIF below.
The 2019 Nobel Prize in Physiology/Medicine was awarded for the discovery of HIF. Without oxygen, the alpha subunit binds to the beta subunit, and (see Fig 1 of this) it interacts with p53 (a protein incorrectly named that way because it apparently had a mass of 53 kDa, whereas it turns out only to be closer to 43.7 kDa) which regulates Bax/Bak which causes the release of cytochrome c, which is a classic step in the intrinsic pathway of apoptosis (one apoptotic pathway). At that point, the steps toward cell death are common knowledge to most people (I'd estimate it's millions) who've studied cellular biology at the undergrad level this century (I actually wrote about apoptosis induced by cytochrome c in a high school essay, but probably went through it in far more detail in BIOL 130 at University of Waterloo).
A surplus of carbon dioxide (hypercapnia) will cause your blood to become acidic and your kidneys to work harder, but it is not "directly" attributed to something like apoptosis, and it would likely take more than 4 minutes to cause death.
In the literature, HIF-induced apoptosis is described as being caused by a lack of O2, not a surplus of CO2. However the two situations cannot completely be separated since they're intrinsically related. In a room that lacks oxygen, your partial pressure of CO2 will build up as you exhale. A high enough partial pressure of CO2 will surely block O2 from binding to HIF1a, which will lead to the same result as hypoxia-induced HIF-related death.