First, make sure all of your important photos are backed up somewhere safe, like your computer hard drive or Google Photos in the cloud, in case something is about to fail on the phone. (It's also a good idea to make sure any other important data is backed up, besides photos.)
Next, try going to
Settings>Apps, select the Gallery app, then Storage, then Clear Cache/Clear Data. Now open Gallery again and wait a few seconds for the database to rebuild. Does the problem persist?
If it still persists, then try using a different gallery app, like Google Photos or
Focus.