Say if I was living in ancient Rome/Athens/Alexandria and I had a small house or lived in an apartment. Did I have a key to get into my front door? What prevented people in the urban areas from just getting their stuff stolen all the time?
On a slightly related, yet mostly different note - where did people keep their money back in those times? For example a Roman solider gets his pay, where does he put it that isn't just easily stolen by somebody walking into their (potentially) unlocked house and taking it?
I can answer to some detail as to what we know about ancient Rome, though I do know that locks and keys are an ancient invention and they have been around at least since the period of Halstatt A (c.1200-1000 B.C.). Locks are also mentioned already in Homer (Od. 21.48), so looks like they've been in use more or less throughout the classical antiquity.
If you owned a small apartment in Rome, yes, you would have most likely had a key to a locked door. Burglarly and thievery were rampant problems in ancient Rome and, with the absence of any trustworthy or effective state police, private individuals were left to their own devices to defend their property and family. Consequently, the Romans pulled all stops to stop burglars from getting to their homes and that includes locks, bolts, chains, and bars. On top of this, you would probably store your valuables in little locked metal boxes.
Interestingly, many of the houses and shops in Pompeii had been carefully locked and barred before the inhabitants escaped the volcanic eruption and chaos - showing how much importance the Romans put on securing their houses. Lock-finds from many Roman sites are extremely numerous and - it appears after a quick scan - rather well studied; already in 1946, Heinsius published a study on the lock finds of ancient Rome, Urformen von Schloss und Schlüssel. So, it seems locks and keys weren't luxury items, and anyone who had any property of value could also afford to protect it. It's difficult to assess just how secure ancient Roman locks were, but the few surveys that have been done on the topic suggests that they were actually quite reliable and manufactured with care; when Weeber in 2002 studied the about three hundred keys that were found at a Roman auxiliary fort in Saalburg, not two of them were identical.
However, it's worth noting that locking your door might not always be much help in stopping burglars. In the Greek parts of the Empire (and in earlier Hellenistic times), a common term for burglars was τοιχώρυχος (toichouruchos), literally 'one who digs through the walls'. The houses of middling families were often build of nothing more than wattle and daub, so simply breaking a hole into a wall was super easy. There are plenty of references in our sources, both in literature and surviving papyrus petitions to authorities, of cases where a burglar breaks into a house either from the street or from the neighbouring house through a shared wall.
Consequently, most Romans did not entrust the control of access to their houses solely on inanimate barriers. The mosaics of guard dogs from Pompeii are of course very famous, and anyone who could afford it would keep a ianitor (yes, where the English 'janitor' derives from) or ostiarius - a slave who's job was to guard the door, and who could be either chained (!) to the main door or have a little lodge next to it. Plus, most Romans also turned to supernatural forces to protect their houses; for example, different painted or sculpted phallic symbols, such as penis wind chimes as known from Pompeii (semi-NSFW obvz), were among the most popular and potent (heh) measures to ward off evil spirits and intentions.
If anyone is interested to read more, this very good and detailed thesis was a great resource on private security in ancient Rome: Private Security in Ancient Rome by Max Conzémius. There's plenty of pictures of Roman doors and locks, plus abundant references to primary literary sources!