A quick search for "how does a gas regulator work" resulted in a clear explanation from the wiki world.
Single stage regulator
High pressure gas from the supply enters into the regulator through
the inlet valve. The gas then enters the body of the regulator, which
is controlled by the needle valve. The pressure rises, which pushes
the diaphragm, closing the inlet valve to which it is attached, and
preventing any more gas from entering the regulator.
The outlet pressure and the inlet pressure hold the diaphragm/poppet
assembly in the closed position against the force of the large spring.
If the supply pressure falls, it is as if the large spring compression
is increased allowing more gas and higher pressure to build in the
outlet chamber until an equilibrium pressure is reached. Thus, if the
supply pressure falls, the outlet pressure will increase, provided the
outlet pressure remains below the falling supply pressure. This is the
cause of end-of-tank dump where the supply is provided by a
pressurized gas tank. With a single stage regulator,
when the supply tank gets low, the lower inlet pressure causes the
outlet pressure to climb. If the spring compression is not adjusted to
compensate, the poppet can remain open and allow the tank to rapidly
dump its remaining contents. In other words, the lower the supply
pressure, the lower the pressure differential the regulator can
achieve for a given spring setting.
The outlet side is fitted with a pressure gauge. As gas is drawn from
the outlet side, the pressure inside the regulator body falls. The
diaphragm is pushed back by the spring and the valve opens, letting
more gas in from the supply until equilibrium is reached between the
outlet pressure and the spring. The outlet pressure therefore depends
on the spring force, which can be adjusted by means of an adjustment
handle or screw.
Double stage regulator
Two stage regulators are two single stage regulators in one that
operate to reduce the pressure progressively in two stages instead of
one. The first stage, which is preset, reduces the pressure of the
supply gas to an intermediate stage; gas at that pressure passes into
the second stage. The gas now emerges at a pressure (working pressure)
set by the pressure adjusting control knob attached to the diaphragm.
Two stage regulators have two safety valves, so that if there is any
excess pressure there will be no explosion. A major objection to the
single stage regulator is the need for frequent adjustment. If the
supply pressure falls, the outlet pressure may change, necessitating
adjustment. In the two stage regulator, there is improved compensation
for any drop in the supply pressure.
I've disassembled the regulator for a helium balloon inflator tank and found it to be virtually identical to the image. For balloon inflation, precise regulation is not important and the regulator was single stage.
It was comprised of a number of o-rings, seating the metal diaphragm to the machined parts and of course, the needle valve adjustment mechanism.
The failure of the regulator requiring repair was erosion of the o-rings and easily repaired.
One could construct a DIY version using a thin sheet of spring steel, but the critical aspect of the build would be to ensure the enclosure will hold the expected pressure. One would not expect a 3D printed pressure chamber to manage any appreciable pressure, although an explosion of PLA or ABS would be less severe than that of steel or other metals.
Off the shelf items for the needle valve assembly might be a carburetor kit for a mower engine or similar powerplant. Experimentation is warranted for the DIY side of things.