Old doors fail to shut properly, or swing open and shut by themselves, for any number of reasons. Houses tend to settle over time, which can mean the doorways are no longer plumb and square.
Check the hinge first. If the pins are not stacked directly above each other, they tend to bind and pop the door open. If so, remove the hinge and tighten it in a vise to bring it back into alignment. Or replace it with a similar salvaged or reproduction hinge.
If the door is warped or out of square, don’t try to fix it. It’s better to trim the stop on the door jamb (the upright piece of the door frame) where it’s rubbing. Shave just a few millimeters at a time with a rabbet plane. Then adjust the position of the striker plate (mating hardware for the latch) until everything lines up—or the door stops popping open, whichever comes first.
If the jamb (framing) is out of square, trim the top or bottom of the door where it binds, again shaving just a bit at a time. Adjust the striker plate as needed.
If the latch is still misaligned with the striker plate, find out how much. Rub a lumber crayon on the plate and close the door; the latch bolt will scrape off the crayon mark, indicating how close it comes to the hole. If the alignment is off by more than 1⁄16", shift the location of the plate: Remove it and reposition it on the jamb so that the hole surrounds the bolt location. Scribe around the outside of the plate with a sharp knife, then around the inside of the hole with a pencil. Chisel out the bolt hole. Screw the striker plate in perfectly flush, then make sure the latch bolt sinks easily into the striker plate hole when the door is closed.