Gyms can hold up to a certain amount of pokemon depending on their gym level. For example, a level 7 gym can hold up to 7 pokemon6 Pokémon, however each trainer can only have one of their own pokemonPokémon on any given gym. To get more pokemon at a particular gym, you must first level up that gym to increase it's defending capacity, then wait for other people in your faction to place their pokemon at that gym.
You can have 1 pokemonPokémon in an unlimited number ofup to 20 gyms, but the maximum defender bonus you can collect from owning gyms is 1050. For example, if I had pokemonPokémon posted at 15 different gyms, I could at most collect 100 pokecoins and 5000 stardust50 Pokécoins every 2124 hours.