It is indeed gravity. You can verify this with a accurate level (test your level by putting against the hinge side door jamb, noting the bubble position. Then invert the level (put the opposite face against the jamb and you should get the same bubble offset) The jamb frame is likely canted. Fixing a canted jamb is very involved: removing door, trim casing from both sides, removing shims and reinstalling new ones.
Fortunately, there is a quick-and-dirty fix for doors that are lightly canted: Cause a hinge to bind (slightly). This will allow the door to 'stick' in position. Try this on one hinge at a time (I like to start at the middle (of 3), so that the door stays in place. Remove the hinge pin, remove the door side leaf. Using a adjustable wrench, adjust the wrench to clamp over one loop (of the (still in place) jamb side hinge). Pry that loop a bit out of alignment. Replace the door side leaf and pin (it should be a little tight). Test door. Readjust as needed (too tight or not tight enough) Other loops of the door side hinge can be similarly adjusted.
If your jamb side screws are marginal, (they move while prying) you should replace them with longer ones, especially on the center screw (of the 3). A 2 1/2 inch screw will lock down the hinge to the internal framing.
Alternatively, if you have access to a vice, you can bend one loop of a removed hinge leaf.
Finally, if you have enough door gap at the hinge side and its clear to you which way to tilt the door (from your level check), you can correct its 'lean' by 'tipping' the door back (towards) vertical by bending ALL the loops of the jamb side of the hinge away from the door. This will reduce the door-to-jamb gap. You would typically do this to only a top or bottom hinge (to reverse the tilt)