One thing that I suspect you're probably missing is that you are likely to be giving off "Don't engage with me" vibes unintentionally.
If you go to a social place like a cafe or a bar or somewhere similar, observe how different people signal whether they are open or closed to interactions with others (often this is quite subtle so unless you're fluent in body language or an avid people-watcher, you may miss the smaller cues so YMMV.)
People who are open to engagement with others will have at least a small smile on their faces, they will orient their bodies outwards towards the open space rather than towards a corner or a wall, they will have their heads up and often they'll be scanning the room or gazing out into the room, and they will do things like make limited eye contact with others who are doing the same thing.
If brief eye contact is made with another person, often that's where there's a subtle exchange of signals that occurs such as a slightly increased smile, a small nod of acknowledgement, a quick raise of the eyebrows (but not in an exaggerated or suggestive way - more like an eyebrow flash that monkeys do to signal friendliness or submission [i.e. "I'm not a threat"/"my eye contact is not intended to be intimidation"]), perhaps even mouthing the word "hi" or a small, open-handed gesture like a raised finger or two or a sort of truncated wave.
Then the next thing is for one of the two people to approach the other, often under pretext, and to start with an opener. This is culturally specific so it becomes more difficult to determine what is appropriate given your cultural context but openers which are neutral and directed at something external and mutually agreeable is a way of signalling intent to engage on a friendly basis rather than seeking to pick someone up, so something like "It's a beautiful day out there" would be the cue for the other person to respond affirmatively and to build on the opener and to leave conversational "breadcrumbs" to signal that they wish to lead the conversation from behind, so their response might be "It really is. It's a nice break from the awful weather we've been having and it's so much nicer walking my dog when it's like this."
The "breadcrumb" there is that the other person is signalling that they want the first person to lead the discussion towards the topic of their dog. "Oh, I love dogs. What breed do you have?"
Etc. Etc.
Once the other person has reciprocated enough and there is an indication that there's mutuality in the conversation after a few more back-and-forths which are kept light and are not too personal, especially when the other person has shown interest in the person who approached them, the person who approached might say something like "Do you mind if I take a seat?" while gesturing towards a nearby seat which is not in direct contact with the other person. A seat opposite them or one which can be reached without having to squeeze past the other party is a socially-appropriate choice, except where it's a particularly small or crowded venue in which case being in close quarters is to be expected and it's generally more acceptable.
This is generally where you would introduce yourself by name and seek the name of the other person before continuing the conversation.
This is more or less how people strike up conversations with other people who are strangers in public venues where people are open to approach. Restaurants at dinner are generally not appropriate. Casual dining restaurants at lunchtime are more appropriate for seeking conversation. Bars are almost always appropriate to seek conversation in. There's a lot of rules...