My apartment door unlocked itself.....a wood kind of one with a round door handle that key goes into. I shook it when I was leaving to make sure it was locked then I came home to find it unlocked....twice. Does anyone please have an explanation for how this could have happened?
Most likely, someone is entering your home without your permission. That is probably a violation of your local tenant-landlord laws, but there are other actors who may not know about or respect those laws.
There are several ways this can happen. Some sites have really, really, really bad security. This very long video covers most of them in its first 20% or so. (the rest is about door sensors, card keys and other non-applicable stuff).
Often they don't change the lock after a previous tenant leaves. Sometimes the tenant is shifty, or sometimes they give a copy of the key to someone else who may not realize that tenant has moved on, such as a friend or contractor.
In all apartments, it is normal and legal for the landlord to hold a copy of your key. That is so they can do non-destructive entry when necessary.
It's possible to build a lock tumbler set so that two different key cuts (bittings) will both work. So your lock works with key bitting A and B... your neighbor A and C, your next neighbor A and D, etc. You are issued key B. Your neighbor is issued key C, next neighbor key D, etc. The landlord holds onto key A, which opens every apartment, as well as utility closets, roof access etc.
But of course the landlord doesn't do all their own work; that's not even legally allowed (workers must be licensed). They hire out to contractors. The contractors need access, so as a simple expedient, they hand the contractor an "A" key. At this point, the contractor (on purpose or by mistake) could enter an apartment. Legally the landlord is supposed to give you advance notice of such an entry unless it is an emergency... but that's not the contractor's responsibility, they're there to "Git-r-Dun" and get paid. In an emergency they are supposed to notify you that they had in fact entered - however they may stick that on the outside of the door and other tenants or the wind may tear it off.
If a "master key" gets compromised, i.e. if a contractor copies it, security for the site is blown. Now the landlord has the ignominious task of having a locksmith create a new "AA" key bitting, and re-key your door so it works with "AA" and "B", your next door neighbor's to work with "AA" and "C", etc. for every door on the premises. The landlord often won't bother, or won't even know the key is compromised.
You need to report the entries to the landlord, for this reason alone.
Because nothing says "peace of mind" like a Chinese lock box clamped to a fence, with your house keys inside.
Lock boxes are lockable boxes with a shackle, typically locked to doorknobs or fences, sometimes bolted to the side of the building. They have a compartment specifically for house keys. Whoever can access the "lock box" has the keys inside.
Some commercial sites infamously have a whole row of these things, one per contractor or service provider. Who knows what keys are in it? These have exploded in popularity in recent years. It is the classic example of the war between "usability" and "security".
This combines badly with the above, e.g. if the management company is dumb enough to put a master key in one, or if the previous tenant put your key in a lock box for a service they once used, and that lock box is latched to a fence, forgotten and waiting for someone to pick it.
Door "dead latches" and strikes
See 6:50 in that video.
You notice the door's latch is just a ramp on a spring. Nothing keeps someone from dragging something (hook, credit card) across the slot and the ramp will make it retract. UNLESS...
Better door knobs have a feature called a "dead latch". It's a typically half-moon shaped "rod" right next to the latch. If it is pushed in, the latch will not retract! It can only be operated by the knob/key. If your door set doesn't have a "dead latch", it needs one.
However, the dead latch has to operate against something in the door frame. That is called the "strike". If the strike is the wrong shape, or misaligned, the dead latch will fall into the hole in the strike, and it won't do its job.
Other jamb problems could even cause the door to hop off the jamb with the wind, and open, and re-close. If the lock automatically unlocks in that case, it could be the wind!
Talk to your landlord.
Anyway, talk to the landlord about your door concerns. Most landlords have no issue whatsoever with you installing premium door knobs (they are pretty standard and don't involve modification) as long as you pay for it and they get a copy of the key. If warranted, you could even use a premium access-control key such as Schlage Primus or Medeco M3... they can't duplicate it and you'd only give them one, so they won't risk leaving it in a "lock box".
If this has happened more than once, motion sensing game cameras are cheap these days and the comment recommending you put up a camera deserves to be an answer. If someone has entered your place and nothing was stolen, especially repetitively, it might greatly benefit you to know who as it could be inappropriate activity by a landlord or something less OK than that. I'd put up a camera and at most re-key the existing lock so a change is not obvious and you have a good chance of getting video of whatever person attempting to enter one last time.
I had my front door crowbarred open about 10 years ago. Still no idea what if anything they took. Thousands of dollars in recent electronics that could have been hauled out rapidly. Initially my roommate thought a box of loose change had been stolen, but I found it a few years ago after he passed away.
It means someone is breaking into your apartment
It's most likely a handy-man or contractor with some bad intentions. Just google "handy man breaking into apartment". In many cases apartment complexes hire people without a background check.
Immediately call your landlord
Tell them you know your door is locked, but you've come home to an unlocked door twice. Hopefully it's an oversight and the person was supposed to be there. If there were no work orders rekey immediately!
Buy a security camera that can stream to your phone
By a camera that will live stream the apartment and save it offsite. You can set it to alarm when it detects movement. If it is a handy-man, you may have just tipped them off, and they'll be more careful to lock-up behind them.
If it is someone on payroll, the security camera will let you catch them red-handed.
Maybe sleep somewhere else until the new lock is installed
Consider staying at a friend's place. The worst case scenario is a very bad person has you in his sights.