Food of one kind or another is pretty much always available on board. You are free to come back to the ship anytime you want for any reason.
If you choose to patronize restaurants/bars ashore, it's completely up to you. You pay the bill like anyplace else. There are no prearranged "safe" places for you to eat ashore, but I suggest to you that it's generally not something to worry about. I see more in the press these days about people getting sick on ships than at port stops.
So I recommend doing what seems convenient and enjoyable.