Homes shift over time as the ground around the foundation shifts. The slight change can mean misalignment for the doors in your house. The first part to fix is the striking plate, the metal part attached to the door frame where the door latches. It will need to be shifted up or down just enough to line up with the latch. Use a chisel to make just a enough room to move the striking plate up.
When doorknobs, locks, and sliding doors begin to stick it is usually due to dirt and grime build up. Use a cutting oil to clean up the mechanics. It is best to disassemble the doorknob or lock to get all the components truly clean. After cleaning and drying all the parts apply light machine oil (e.g. sewing machine oil). The oil will keep the assembly lubricated and working seamlessly. If you're not looking to go into that much work WD-40 does a good job of cleaning and lubricating at the same time. Plus, the nozzle attachment makes it easy to spray into small holes and key slots.