To take over a gym you have to lower it's prestige all the way to zero in order to make it 'neutral' before you can station one of your Pokemon there. This can involve beating a gym several times unless you have some team members around to back you up. You can see how many gyms you control in the 'Shop' section of the game.
Taking Over Gym
from PoGo Admin | 11th Jul 2016