Nothing is "shared to Gallery". Gallery is an app. It shows any pictures located on the phone or backed up to Google. Assuming you're talking about Facebook Messenger, not some other messenger app, look in the messenger app for Settings, and disable saving photos. (You can't save them to the phone and not have them showing in Gallery - the closest you can come is to save them on the phone and not have them show in any app except file managers. You do that by putting a file named .nomedia [yes, starting with a '.'] in the folder that the pictures are being saved to. [What's in the file is irrelevant - it can even be a 0 length file - a file with no content.])