Substances don’t have to be a liquid or a gas to behave like a fluid. Swarms of fire ants display viscoelastic properties, meaning they can act like both a liquid and a solid. Like a spring, a ball of fire ants is elastic, bouncing back after being squished (top image). But the group can also act like a viscous liquid. A ball of ants can flow and diffuse outward (middle image). The ants are excellent at linking with one another, which allows them to survive floods by forming rafts and to escape containers by building towers.
Researchers found the key characteristic is that ants will only maintain links with nearby ants as long as they themselves experience no more than 3 times their own weight in load. In practice, the ants can easily withstand 100 times that load without injury, but that lower threshold describes the transition point between ants as a solid and ants as a fluid. If an ant in a structure is loaded with more force, she’ll let go of her neighbors and start moving around.
When they’re linked, the fire ants are close enough together to be water-repellent. Even if an ant raft gets submerged (bottom image), the space between ants is small enough that water can’t get in and the air around them can’t get out. This coats the submerged ants in their own little bubble, which the ants use to breathe while they float out a flood. For more, check out the video below and the full (fun and readable!) research paper linked in the credits. (Video and image credits: Vox/Georgia Tech; research credit: S. Phonekeo et al., pdf; submitted by Joyce S., Rebecca S., and possibly others)
ETA: Updated after senoritafish rightfully pointed out that worker ants are females, not males.