What determines which pokemon you are allowed to place at a gym?
I'm pretty sure a Pokemon needs to be at full HP to be placed in a gym, so the reason yours wasn't available was because it was hurt from the previous battle. Heal it to full with potions and it will be available.
Your pokemon needs to be:
-Full hp
-Not actively in another gym
Tips:
-Keep your best pokemon of each type with you, put the 2nd best ones inside gyms.
-Try to put pokemon that are not weak to the pokemon types in that area. For example, do not put water pokemon in gyms where there is a lot of electric pokemon spawns. Or you'll lose that gym immediately.