Tighten each of the screws that secure the hinges to the door frame with a screwdriver. Close the door and actuate the lock if the hinge screws were loose, as tightening the screws may have solved the alignment problem.
File down the strike plate to cure a minor side-to-side alignment problem with a metal file. The strike plate is the metal component located in the door frame into which the lock passes through when engaged. If necessary, determine which portion of the strike plate to file by dabbing nail polish on the tip of the lock bolt, closing the door and engaging the bolt. Open the door and look for the nail polish on the strike plate. Remove the nail polish with nail polish remover.
Hold a straightedge at least three feet in length against the sides of the door to determine whether the door is warped. Check both ends of both sides of the door. The door should rest against the entire length of the straightedge. Consider replacing a warped door.
Close the door and measure the gap between the top of the door and the bottom of the door frame, on both ends of the top of the door, with a measuring tape to determine whether the door is out of square with the frame. The door is out of square if the measured distance is greater on one side of the door than on the other. Adjust an out-of-square door with door shims. If, when facing the door, the left side of the door is lower than the right side, add a shim to the bottom hinge. If the right side is lower than the left side, add a shim to the upper hinge. Remove the screws that secure the hinge to the door frame with a screwdriver, then slide the shim between the frame and the hinge. Tighten the screws through the shim and into the frame.