If you try a search for exactly that, you'll get lots of information. The best overall explanation I've seen of how each type of 1st stage operates is in the Vance Harlow book on regulator repair. Another good one, more detailed but also more difficult to understand, is in a book called "reg savvy" by Peter Wolfinger.
Basically, the way any 1st stage works is, there's a valve that is formed by the junction of a seat and orifice, and that valve is held open with a big spring when the reg is not pressurized. When pressurized, air flows through the valve, filling a chamber to a point at which either a piston or a diaphragm is forced in the direction against the spring and closes this valve, shutting off further air flow. So now you have two chambers in the 1st stage, one at tank pressure on the "upstream" side of the valve, and one at this specified pressure (usually around 125-150PSI) which is on the "downstream" side of the valve. This is the intermediate pressure (IP) chamber. There are ports in this chamber leading to the 2nd stage. When you inhale, you lower the pressure in the 2nd stage, which then lowers the pressure in the IP chamber, which then opens the 1st stage valve and allows air to flow from the tank, which quickly fills the IP chamber, forcing the piston or diaphragm to close the valve, etc. This cycle repeats with each breath.
There are two basic piston designs, the flow-by unbalanced piston like the SP MK2, and the flow-through balanced piston design like the MK25. You'll need to see a diagram to get a good idea of the difference. It's important because the two of those are quite different in performance, so if you're trying to compare piston vs diaphragm you really have to specify what kind of piston design you mean.
Diaphragm regs do the same thing, its just that they use a thick rubber or composite diaphragm and a couple of metal parts to accomplish the same thing. Diaphragm 1st stage valves are unbalanced upstream by design, so practically every one made in the last couple of decades uses a balance chamber to "balance" the forces acting on the diaphragm from the tank. This allows more precise IP setting that remains consistent from a full to an empty tank. The flow-by piston design is unbalanced downstream by design, and some manufacturers, like Sherwood, came up with ingenious ways of counteracting those forces to stabilize IP over the whole tank pressure range, and the flow-through piston regs are balanced by design. Consequently, some of the earlier flow-through piston regs, like the MK5, are extremely simple and very high performing.
If you're trying to decide which is a better design for diving, there is no correct answer, there are great and not-so-great regs of each design easily available. Try not to worry too much, even the cheap regs these days are super reliable and deliver lots more air than you'll ever need. New divers often buy high end regs out of sales pressure, hype, extreme concern about their safety, etc...when just a few decades ago professional divers were routinely making extreme dives on regs that many OW students wouldn't take in a pool today. It's too bad, actually. Some old regs are still great performers and fun to dive with.