The following answer pertains specifically to German submarines (U-boats) from the World Wars, as this is my area of expertise use. But since all submarines of this era shared the same basic design, the following info is broadly applicable to other navies as well.
The short answer is that they didn’t make or carry oxygen because they could not stay submerged long enough for this to really be necessary. They were primarily surface vessels that could also travel underwater for a limited period of time when needed. Either way, the biggest challenge was not availability of oxygen but rather build-up of CO2. U-boats did have a CO2 filtration system, although it was of limited use.
Pre-Cold War submarines were really not true submarines in the modern sense. That is, they mostly traveled on the surface and only dived when closing in for attack or escaping from the enemy. This was because their diesel engines could not be run underwater, since they would quickly deplete the crew’s oxygen while filling the boat with diesel exhaust. They had to rely on battery power when traveling submerged. The batteries (which were charged by the diesels while running on the surface) could only last a couple of hours running at top speed….which was a blistering 10 miles per hour.
So whereas modern submarines spend most of their time submerged, submarines in the first half of 20th century could not. When a U-boat was spotted by enemy forces, it quickly dived beneath the surface. Whatever air was inside the pressure hull at the time was all the air they had aboard until they surfaced again. While on the surface, the main hatch was usually opened so that fresh air could enter the boat. Upon surfacing, they would often ventilate the boat by closing all openings except the main hatch and then revving the diesels. This sucked fresh ocean air in through the main hatch and was generally a huge relief to all aboard, especially if they had just been underwater for a while.
Now, there were instances where a U-boat would try to hide from the enemy by laying motionless on the seafloor. Most of the boat’s electrical systems would be shut off for maximum silence, so there was little battery power being consumed. This was when CO2 became an issue. With 45-55 men inhaling & exhaling inside a 220-foot steel tube, that CO2 scrubbing system is only going do so much. CO2 became a major issue around 24 hours on the bottom, and would reach fatal levels by 72. U-boat sailors were issued a primitive rebreather device (which therefore contained a CO2 scrubber) for escaping a sunken submarine, and these would often be worn by the crew if they found themselves on the seafloor for a prolonged period of time.