This seemingly innocuous question has been on my mind for the past week, so I thought I'd share my thoughts on it and (hopefully) get some helpful insight.
First off, I started by trying to craft a definition of "sandwich" that was as basic as possible. This was "anything surrounded by processed grain" which I immediately found problematic (as I expected it to) because this would include spaghetti and other pastas that we definitely wouldn't colloquially consider to be sandwiches. So I tried to narrow this scope a little bit by redefining a sandwich as something that was surrounded by bread. But this lead to a huge problem because defining exactly what "bread" is was a more complex undertaking than I'd anticipated. For example: do lasagna noodles or cake count as bread? If I restricted myself to only using leavened "breads" that would eliminate matzos, pita, and other such flatbreads. So I scrapped that definition and decided to accept that my ontology would necessarily have to include things like lasagna, pizza, and gyros as sandwiches even though they aren't colloquially considered sandwiches.
I never reached a full definition of what a sandwich was, so I'm opening the question up to you guys to see where we can go. I think this question says a lot about how we group things together and almost subconsciously consider things to follow certain patterns without actually realizing what those patterns are.