Vibration from engines, pumps and machinery can gradually loosen nuts, bolts and studs until parts rattle free. A few drops of threadlocker on the thread before assembly fill the gaps between the metal parts and cure without air to hold the fastener in place.
All three grades here are from Loctite, and the choice depends on whether the fastener will need to come off again. Use Loctite 222, the low strength grade, on small screws and fasteners that may be adjusted. Loctite 243 is the medium strength choice for general nuts and bolts that may need removing with ordinary tools, while high strength Loctite 263 is for fasteners meant to stay put.