When you attack a player or AI castle or a wolf lair your troops follow a very basic idea and that is to march straight to the keep in the middle. Certain units like pikemen or swordsmen will march straight into to the keep without stopping unless a unit blocks their path e.g. another pikemen or swordsmen.
Archers will always stop and fire on units within their range no matter what the unit type
Catapults don’t move at all during battle and instead fire on whatever you target or fire randomly at anything within range.