Tramming, often referred to as "leveling" in the 3D printer world ("tramming" and "leveling" is used interchangeably, but "tramming" is the correct nomenclature), is the process of creating a 2D plane of the build surface that is parallel to the nozzle at the whole print area (usually the X-Y plane).
In order to adhere the hot filament from the nozzle it is essential that the distance between the nozzle and the build surface is as constant as possible. Increase of the gap may cause the filament to not be squished enough and it may be dragged instead of deposited or create an insufficient bond to cause problems later in the print job when e.g. shrinkage of the object comes in play.
To tram the build surface (a build surface comes in many shapes and forms, sheet of glass, bare aluminum plate, some sort of coated heated surface, etc.) most printers are equipped with at least three so-called "leveling screws". Why at least three? It takes a minimum of three screws to fixate a plane in space, more screws cause the bed to be over-defined or indeterminate, but with a flexible build surface it is quite common to have 4 screws although it is causing a statically indeterminate system. So, these screws need to be adjusted as such that the build surface if parallel to the nozzle.
First step is to home (What is homing? What is the purpose of homing?) the printer, homing from the tag wiki reads:
The process of determining the location of a 3D printer nozzle in three dimensions using a reference point (home location) is referred to as "homing". Homing should occur before every print and involves bringing the X, Y and Z-Axis motors to pre-defined limit locations (usually these are endstops). Pre-recorded homing data offset values determine the position of the build plate origin with respect to the endstop locations.
Once homed (with G-code or through the graphical user interface of the printer display) , the origin (0, 0, 0) of the printer is known, from this origin you can determine the level. Note that the X and Y is usually correct (if not, see How to center my prints on the build platform? (Re-calibrate homing offset)) the Z offset depends on the height of the Z endstop and the leveling screws. For a surface that uses a sensor as endstop (see e.g. Automatic Bed Leveling (ABL) with a sensor (BLTouch, inductive, capacitive), how does it work?) the offset is defined by G-code (G28) or through the user interface of the printer display. Note that automatic bed leveling (ABL) is not magic, you still need to provide a trammed bed that is as level as possible, the sensor merely scans the surface and adjusts for larger imperfections of the build surface. After homing, move the nozzle at a certain Z value to the corner of the origin, which is usually the front left) (0, 0, Z) or close to this corner (10, 10, Z), put a piece of paper (A4/Letter) on the build surface and lower the Z to 0 (or if you hit the build surface before you reach zero height, then lower the build surface) raise the build surface until you can feel the the paper drag slightly when pulled between the nozzle and build surface (alternatively you can use a feeler gauge, A4 paper is 0.08 to 0.11 mm thick, so a 0.1 mm gauge will do fine). To be sure that the carriage hasn't been moved by the tramming, issue a homing command and move to the corner to the right and repeat the process to crete a slight drag of the paper when pulled between the nozzle and build surface. Note that tramming this point may have influenced the first point. Now repeat the homing and moving (for corners back right and back left) to start over again at the front left corner and repeating the whole process at least one to two times. This iterative process will deliver a trammed bed, the bed should now be parallel to the nozzle.M851
Once trammed the build surface should be parallel to the nozzle, if the distance (usually paper thickness) is too far or too close, adhesion or first layer deposition may fail or cause surface defects like ripples. If not adhering the initial gap between the nozzle and the build surface (paper thickness) might be too big, making this smaller may help squish the filament more so that it adheres better to the build surface. Alternatively use an adhesive in between the build surface and the first layer, nowadays there are multiple dedicated sprays and liquids available, but some house hold product like wood glue, glue sticks and hair sprays could be used.
When the build surface isn't perfectly flat, tramming is a challenge, or doesn't provide a 2D plane at a fixed distance of the nozzle. In such cases, scanning the build surface and adjusting during printing might help to get the filament to adhere properly; this process is called automatic bed leveling or ABL (see Automatic Bed Leveling (ABL) with a sensor (BLTouch, inductive, capacitive), how does it work?). An alternative is UBL (see What is ABL or UBL? Is this the same?).
The frequency of tramming depends on the quality and (mis)use of the printer to maintain the 2D plane parallel to the nozzle. For good quality printers the tramming is performed very seldom.
They are all generic guidelines. Don't count on them too much.
What you need is a reproducible offset to get the same value everywhere in the bed, then you can correct the overall offset via gcode at the beginning of your print.
You can also get an approximate Z-offset value, then print a solid 30x30x5 mm cube.
If, starting from the third-fourth layer, you see some over-extrusion, you need to adjust the extrusion multiplier or the E steps calibration and reprint.
Once the solid cube looks good starting from the third-fourth layer up, then you can tune the Z offset by printing a cube which is only 0.2 mm high (or 0.25 mm, or whatever your first layer height is).
If you see over-extrusion, the Z offset is too big. If you see visible gaps between extrusion lines, the Z offset is too small.
If unsure, better get some small remaining gaps rather than overextrusion and excess material.
The idea is that extrusion issues in the first layer can be caused either by the offset or by the multiplier, so you must adjust the multiplier first by looking at the print after about 1 mm height (the first layer issues tend to disappear after some layers). Once you know the extrusion is right, set properly the first layer.
Edit
For a good guide check Andrew Ellis' guide: set first the extrusion multiplier and then the first layer squish.