How to stop screws from loosening
Screws may become loose due to vibration or insufficient friction in the mating surface or both. If a screw is subjected to vibration constantly it is likely to work itself loose over time. If a screw is inserted into a substance that cannot provide sufficient friction, it will be loose.
For example a screw installed into wood that has worn down over time and no longer maintains the opposite thread pattern from the original installation of the screw will not provide sufficient friction to keep a screw tight.
Apply thread locking glue to the threads of your screw before installing it. Tighten it to the manufacturer's specifications (do not over tighten). Allow the glue to dry before using the screw to hold tension.
Fill in the screw hole with additional material to provide increased friction. If the hole is in wood, break off the end of a wooden match stick or skewer into the hole (or several if necessary for a larger hole) before reinstalling the screw. Adding thread locking glue will aid in the creation of friction to keep the screw tight.
Wrap the threads of the screw with some cotton for "set screws" which are types of screws that hold things like doorknobs in place. Wind the thread around the shaft of the screw in a clockwise direction and dab a few drops of thread locking adhesive to the cotton to hold it in place. Cut off the excess thread and install the screw in place according to the manufacturer's specifications (do not over tighten).