All bodies of any size carry with them an envelope of air whenever they leave the surface of a planet or other stellar object. Unlike real-world astrophysics, this air envelope is not dispersed by the vacuum of space.
A typical human will drag enough fresh air with him/her to breathe for 2-20 minutes. After that time runs out, the air will turn foul for a like period of time and then become deadly. The amount of air a spelljamming ship carries with it is based on its size – the larger the vessel, the more air is dragged into its pocket (these bubbles of air provide breathable atmosphere for varying lengths of time, but 3 months is considered "standard").
Air is relatively easy to replenish. Entering a larger air envelope like that of a planet or asteroid is one of the most popular and cheapest methods. Green plants will refresh air; some vessels make great use of these for just this purpose. Many asteroid colonies keep at least half of their surface area reserved for plants for this reason as well.