When you are done wth a piece of equipment, wipe it down. Don’t walk barefoot in the locker room.
20 years a gym rat here. I've walked barefoot on every locker room floor from my high school to college and a dozen gyms in between and never once had athlete's foot or any other foot ailments. The key is to keep your feet dry and to wipe them thoroughly with a clean towel before putting on your socks.