I believe the powder may already have oxygen as part of its makeup.
That is correct, explosives in general already contain everything they need, chemically, in order to create a violently fast reaction, although many do also need containment in order to explode rather than burn (including nuclear weapons, even though they are not chemical in nature).
Regardless, the primer also creates a compression scenario, which works much like a diesel engine (increased pressure = better combustion).
Well, in the case of gunpowder (black or smokeless), a large amount of oxygen is still needed and is locked in the chemicals until it is released; it usually comprises most of the explosive material, actually, such as the case of potassium nitrate in black powder. While the primer contributes some pressure of its own, its main function is to ignite or detonate the main charge of powder, of course, which then builds its own pressure within the confines of the cartridge case (temporarily plugged by the bullet).
In analogy, the primer is more like the spark plug of a gasoline internal combustion engine than it is any part of a diesel engine, and in addition the propellant is already pre-compressed in solid form with its own oxygen inside a small container rather than actively compressed as a mixture of fuel and oxygen from the air.
Free gunpowder will burn. Contained gunpowder (as in a cartridge or powder keg) explodes.
Yes, when it's contained pressure is allowed to build, which in turn speeds burning, resulting in a lot of pressure escaping very quickly (i.e. an explosion), pushing the bullet out at high velocity during the process. This has little to do with the primer creating compression, however.