I think this is a cultural thing. I grew up somewhere around Europe and random people talking to me on the street would be a big nono, I would run for my life; would definitely at least give a weird look and increase my speed. When I moved into the Bay Area for undergrad I saw this is completely normal here. So, I started talking to randoms too, and it usually feels very much when you feel lonely and at the supermarket and some dude asks about what you're cooking tonight.
That's really fascinating to me. I live in LA (for over 3 years now) and literally no one on the street, in a restaurant, or a store has ever just started talking to me. I would be startled and probably expect you to ask me for money if you did that to me here. Is the Bay really that different?
Never lived in LA (been there for a few hours once), so I don't know. In Bay Area I lived in Berkeley for about 4 years and occasionally visited San Francisco and the the South Bay for entertainment etc, I would say the cultural atmosphere is similar. As I said I was talked to by strangers on the street (and especially in a market e.g. Trader Joe's, Safeway, The Dollar Tree etc...) on multiple occasions.
Currently living in Boston, MA. It's definitely not as usual as the Bay Area, people are significantly "colder" (for the lack of a better word) but I wouldn't say talking, or smiling to a stranger would be as weird as in Europe. Maybe LA is different than both the Bay Area and Boston area (although Boston being in itself significantly different than the Bay Area in the first place)
No offense, but it might have to do with the way you seem to strangers. You get a sense of a person and sometimes you feel that you can talk to randoms; that they're interested and/or you're on the same mental wavelength. These senses are important, because even in the USA, where talking to randoms is common, you still want to avoid "bothering" people. So there is still risk of inconveniencing someone with an unwanted conversation, or making them feel uncomfortable, and this is still a big social no-no.