Theft in dorms is opportunistic almost by definition, valuables left in the open, and that means simple habits eliminate most of the risk. Incidents are uncommon in well-run hostels, but every long-term traveler knows someone who lost a phone or cash by leaving it charging unattended, so treat prevention as routine rather than paranoia.
The core system: use the locker, always. Bring two sturdy padlocks of your own, one for the locker and a spare, since hostel-supplied locks are inconsistent. Passport, cards, electronics, and cash go in every time you leave the room and while you sleep. Keep a small day-money stash separate from your main cash and cards, so no single loss is catastrophic. At night, phone and wallet sleep in the locker or inside your pillowcase, not on the bed shelf; sleeping travelers are the softest target.
Upstream of all this, book hostels whose reviews confirm working lockers and key card dorm access, because most thefts trace to outsiders wandering in or lockers nobody uses.