At this stage, your toddler is playing alongside friends rather than with them: parallel play rather than cooperative play. Toddlers aren’t particularly social, but that doesn’t mean they don’t enjoy playing with other kids. On the contrary! They view their friends kind of like fun toys. And they view their friends’ food and toys as shared property that they can just take.
We are not born social and generous. We learn those traits by being with others. Children aren’t particularly good at making friends at first – but they get better and better at it over time. They have to practice. Let them gradually make a friend or two with whom they can play for short stints of time. It’s a good start.