In order to conquer a planet you have to destroy the entire planetary-defense of a planet, plus all hostile ships in orbit of that planet. If the owner of the planet you are attempting to conquer is allied with another player who has ships present at the planet these ships may participate in the combat and will also have to be destroyed to conquer the planet. If you have any sort of treaty with this 3rd party, be it an alliance, peace treaty, or cease fire, then that player will not participate in the combat. Otherwise this 3rd party will participate in the battle and will also have to be destroyed in order for you to conquer the planet. This can potentially put you into a battle with a much larger player without a formal declaration of war and this player will not have to fear a loss of reputation as detailed here. If you are the much larger player this can allow you to neuter a potential opponent without loss of reputation. If combat occurs anywhere except over a defending allies planet than all normal reputation rules apply.
Once you have done that, you need to send a ship equipped with a Troop Bay to the planet, which has the “Conquer Planet” command given. This works very similar to settling a planet. If no defenses are left, the planet will be conquered, the ship with the troop-bay destroyed, and its crew converted to new citizens of the planet. If adding the crew of the Troop Bay equipped ship to the existing population causes the planet’s population to exceed its natural population limit the excess population will become stationed military.
Military stationed on that planet have no effect. They will not help you to defend against a troop-ship. However, this might change in a future version.
If you want to prevent your own planet from being easily conquered, position at least one ship in its orbit to guard it, even if it’s unmanned. Even better, of course, install a minimal planetary defense. Either of these will at least prevent an enemy from simply flying to your planet with only a troop-ship, and taking it over without a fight.