I leveled a friendly gym to level 8, which in turn opened up a slot for my Pokemon. When I went to add one of my own, the "Defend" button was nowhere to be found. I looked into the gym and it did in fact have a slot open. However, every time I tried to add, there was no button. I walked away and after about 10 minutes later, someone else added their Pokemon. Why is this?
There may be someone that beat you to adding a pokemon to the gym (or started viewing it before you). It's basically like a waiting list. When that person finishes their action, then it opens up for the next person. This is to prevent people that came to a gym after someone else was already trying to add one from stealing that gym spot.