In most major cities worldwide, public transport is safe in the way that matters: violent incidents against riders are rare, and millions of locals, including women and kids, ride daily. The realistic risks for tourists are pickpocketing and bag theft, which concentrate exactly where tourists do, on airport lines, at major interchange stations, and on routes serving big attractions, and especially in crush-loaded carriages where contact feels normal. Crowding is the pickpocket's cover, so your highest-alert moments are boarding scrums and packed rush-hour cars.
The habits that neutralize most of it: keep your phone and wallet in front pockets or a zipped bag worn forward, don't stand near doors absorbed in your phone, since door-snatch theft at stops is a classic, and be slightly suspicious of artificial commotion, spills, or strangers pressing unusually close, which are standard distraction setups.
Calibrate to your specific city with quick research, since safety reputations differ enormously, and note the local transit etiquette too.