There are two different proceedings, according to whether or not the territory has a fortification. If it has such a facility, to conquer the territory you need to take possession of the fortification. This procedure is described in Fortifications. If it does not possess such a facility, to conquer a territory you need to subdue its inhabitants.
According to the involved army/armies size and the total population of the territory, the army/armies involved will produce an estimate of how much time it will take to subdue the local population. Being an estimate, there will be a small difference between that and the real time required to conquer the territory, and after that the territory joins your Land!
The number of days needed to conquer a territory without a fortress is roughly equal to the total population of the territory (multiplied by their loyalty) divided be a fifth of the army/armies power (multiplied by their status ). The result will then be affected by the difficulty of the terrain, so it will take longer to subdue the same number of inhabitants of a high mountain than it would in plains.
When a conquer attempt is successful (enough days have gone by subduing the population), that territory will join the realm of the army that first started the procedures, since friendly and allied armies can help each other in such proceedings.
Naturally, the starting loyalty of the newly conquered population will not be high, it will depend upon the loyalty to the previous owner, in an opposite relation (the lower the loyalty to A, the higher to B when B conquers the territory), with a maximum value of 50%.