IT's a sign of stress.. usually from poor water conditions.
Bettas need to be kept in 2 gallons minimum. In these twice weekly water changes of 50% and 100% are needed. Bettas kept in 1 gallon containers live an average of about 2 years compared to double that+ in larger containers. The 1 gallon would need 3 weekly water changes of 50%, 50% and 100%, and even then they will be subjected to ammonia. A half gallon will need alternating 50% and 100% changes daily and it should only be a very temporary home.
The 50% changes the betta can be kept in the bowl and use a turkey baster to remove half the water and as much of the debris as possible. For the 100% you need to remove him - scoop him out with a plastic solo type cup and set aside while you thoroughly rinse the bowl and gravel to remove the debris. Then he should be acclimated to the new water by floating for an hour while you slowly add a couple tablespoons of new water to the cup every 10 minutes. When you release him, try to let as little of the old cup water back into the tank as possible. All water changes should use same temp water, matched to running tap using the in tank thermometer and the water needs to be premixed with conditioner before adding it to the betta tank. If you don't already have anything, you can use gallon water jugs from the grocery store - rinsed thoroughly in hot water but no chems.
Most people will tell you that you can't ever fully cycle a tank under 5 gallons, despite your filter, and you will always need these changes.. you can try, but careful daily monitoring and reliable test kits should be used. You need to be testing daily with a reliable drops kit for ammonia and nitrite and doing an extra 50% change any time you see either. In addition to this a weekly 50% with siphon or new fresh turkey baster that has never seen chems is needed to remove poop and other debris from the gravel. It is not enough to just scoop water off the top ever. I actually suggest a turkey baster or very small siphon because your tank is so small an average siphon will remove water too quickly.
First you will see ammonia, then nitrite. Eventually, hopefully, you will see ammonia fall and stay at 0 even after a week of no water changes, and finally nitrite. At this point you will be left with only nitrates after a full week of no changes and these can be kept <20ppm by twice weekly 50% change with baster/siphon. However, cycling will take up to two months to complete and many if not most people will tell you that you can't cycle a tank of this size and you will always need twice weekly 50% and 100% water changes or you will always see ammonia continuing to build and the cycle will never finish..
Bettas are tropical fish and must be kept at a temp between 76-82, with 78-80 being ideal. The temp must be stable and not be dipping or jumping around. In a 2 gallon you can get an adjustable 25w heater. Any new heater should be tested for 24 hours in similar size container with in tank thermometer to make sure it will hold a constant appropriate temp between 78-80F. Then the betta must be acclimated to higher temp either by floating in a cup inside the main already fully heated tank for an hour, or by adjusting the heater to increase the temperature of the tank no more than a degree per hour and 5 degrees per day.
Flakes aren't good nutritional value, and especially with something this small they muck up the water quickly causing excess ammonia. You should look for a good quality pellets whose first two or three ingredients are whole fish, not fish meal or wheat. He should be fed two small meals a day (how many depends on the pellet you pick up) and one fast day a week.