Building units generates a small ammount of threat, so a large scale increase in your army will make countries notice. Now if you look at the Yugoslav deployment in the first screen shot the AI had evaluated that the Axis members (Italy and Germany) were on the list of two countries deemed most likely to invade Yugoslavia and the majority of its troops were deployed on those two borders. The Italian build up was matched by the AI as best it could while not stripping the German frontier.
I assume that the threat affects have been balanced so that an at war Canada does not trigger a US invasion.