A lot of actions in game happen with a countdown that lead to an event. This can be for example troops travelling to attack a village, which ends with a battle, or upgrading a building.
Naturally, the events are happening chronologically as they finish. So something that happens at 10:05:20 will be processed before something that happens at 10:05:21.
Troops are always last
This is more complicated for events that happen at the same second. In general, troop movements always happen at the end after other events, such as finishing building or arriving merchant.
The order within troop movements depends on who was sent out first. Troops that were sent out earlier will reach the target village before other troops that will land at the same second.
This means that if there is an attack incoming, it is no longer possible to send reinforcements to the village in such a way that they would reach it on the same second, but before the attack. The only way for them to take part in the battle is if they reach the village at least a second before the battle.
However, if there were reinforcements already on the way and then the attack was sent to reach the target village at the same second, the reinforcements will reach the village before the attackers.
Builds, merchants and other events
As for other types of events, there is no guarantee in which order they will be resolved (except that it will be before battles). For example, if warehouse is to be finished at the same time as merchant will arrive in the village, there is no guaranteed outcome of which one will be finished first.
Events in different villages
In addition, there is no guaranteed order of events happening in different villages. This means that if in the same second a village is attacked while troops from that village reach another one in their own attack, those battles could happen in any order.
Some actions in game are instant and are not processed as events (there is no countdown). In such cases they are usually processed instantly (when possible) and there is no guaranteed order between them and the events.