Welcome to Fishlore!
I agree with angelfish and BettaCouple. This sounds like swim bladder, and the size of the tank is likely stressing the fish, making it more susceptible. I have also heard that if
goldfish eat pellets (which is often the form that the food comes in at pet stores), they can get air in their stomaches, which can translate to swim bladder problems, as well. If you do have pellet food, try soaking it in a bit of tank water (or better, VitaChem if you can get it) beforehand. This will remove a lot of the air from the pellets.