Listing ("and"):
Companionship ("with"):
The particle と has two main uses:
As a connector ("and")
Used to list items, typically nouns, that are treated as a set. It implies that all listed items are included, leaving no room for ambiguity.
Here, it is clear that only apples and bananas were bought – no other items.
や, on the other hand, connects items in a list but implies examples among a larger, unspecified group. It suggests that the listed items are not exhaustive.
As a marker for companionship or interaction ("with")
Indicates that the action is performed together with someone or something.