When a betta fish wants to either intimidate a threat or attract a mate, they’ll puff out their gills. The only other reason noted for puffing their gills is when their environment suddenly changes or if they’re startled by something. Two females in close proximity will flare up to each other in order to set up a pecking order.
Not all betta fish will wish to fight and get involved in fights. Sometimes, they’ll seek sanctuary under a rock or in a home in the tank rather than try to challenge another betta fish. However as many people have seen, betta fish are highly territorial and they’ll first set up a territory for themselves. They may use a rock, a plant or something inside the tank and mark it as their territory. If any rivals or other fish are to pass by their territory, they may flare up and try to fight the rival fish.
In history, male betta fish fighting gambling events were hosted and usually for money. The result was usually always with one fish being killed near instantly. If you have male betta fish, you’ll need to separate them in order to avoid any possible fighting. Betta fish will even try to fight their own reflection in a mirror if there’s a mirror present in the tank. Females however have been known to live together just fine without any issues, it’s just the males that fight due to their territorial nature.