It varies with the gun and the amount of play. The old method worked on soft-slide government issue pistols from the WWII era involved first squeezing the frame ways inward using a special set of vice jaws. You would tighten the jaws then strike the vice with a deadblow hammer to stress relive the slide and help it take a set in the new position. Then check the slide and frame fit for horizontal play. Repeat until it is difficult to get the slide on. This can still be done on modern slides, but their heat treatment is different and harder, so this approach takes more effort if you try to use it.
Having taken the side-to-side play out by narrowing the slide ways, the next step is to remove vertical play. This is done by hammering the rails on the frame down until they squeeze down against the ways in the slide. Special tools are made for this purpose. Principle among them are a set of flat ground anvils. You determine how much vertical play has to be removed by seeing how thick a feeler gauge you can jamb inbtween the bottom edge of the slide and the frame. You remove the slide and measure the height of the channel under the rails and select the anvil that is less by the amount of vertical play you need to elimenate. You then hammer the rail down against this anvil to achieve the desired dimension. Final fit is by lapping the slide and rail together.
Other tools and variations occur. Some people peen down the whole rail length on the frame, while some just peen down the rails fore and aft of the magazine well. This is because the metal is thin around the mag well, and it is easy to hammer it narrow by mistake. A mag well solid insert is available to prevent this if you want to peen rails their whole length. A special punch to make the peening more uniform and to avoid hammer or small punch marks is likewise available.
In most instances the peening of the rails spreads them enough that they will take up both vertical and horizontal play. This makes the first step of narrowing the slide ways unessessary. You peen, then file the rail width back to fit the slide width using a flat file that spans the whole length of the rail. Use a micrometer to check width and parallelism. Then you lap.
For detailed descriptions of the procedures read Hallock's and Kuhnhausen's books.
Nick