That's my take on it.
he had to either leave it unlocked or somehow get the keys to it later. He's a maintenance guy -- he doesn't have a master key to every door in the complex. There is probably a keyboard or lockbox in the office with the keys to the individual units.
Maintenance leave vacants unlocked sometimes so that the vendors can go in and out without them having to go to the office and get keys. It's not a good practice, it's just reality. Many offices have keys coded, but 9 times out of ten, the code sheet is nearby and a 3 year old could figure it out. If he was told to trash out the apartment and do basic make-ready stuff, which a porter does, it may have been unlocked for him, or he was given the key. He could have returned the key after leaving a window unlocked in order to get back in and unlock it later.
To get an apartment ready for a new tenant, these are the individuals who usually have to gain access - and in the order they would need to go in:
Manager - walks the unit to assess damages
Lead Maintenance - walks unit to schedule work to be done
Porter - trashes out (removes trash and anything else left behind)
does a basic make-ready (removes caulk, takes electrical and switch plates off to soak, takes down bad blinds, etc.)
Make-ready - Makes sure all appliances, electrical, and plumbing items work - sometimes the make-ready paints the apartment
Painter - paints
re-surfacer - shoots bad tubs and counter tops
Carpet layer if new carpet is being laid
Housekeeper
Carpet shampooer
Locks are changed
Sometimes this all happens in the span of two days - the novelty of taking out and putting back keys in a busy office or by maintenance is a pain and they let it slide from the porter on. However, I thought I read these vacant units had lock boxes. I know I read that in one report, the apartment upstairs. Maybe it was a lock-out knob that had been placed there on a delinquent tenant.