I'm not sure how the AI weighs its tech research decisions, but for military it should be related to many factors including "which" races it encounters (or how diplomacy is developing per turn).
There's 3 factors:
Personality and strategy both have weight values to determine what the race 'prefers' at any given time. Then the techs themselves have weights on which determine how valuable they are to races with those weightings. The AI then creates a random weighted array of all the techs available and rolls a virtual dice - so say thre's one tech with 10 weight and one with 50, it has a 5/6 chance of picking the weight 50 tech.
Now, the only thing in there which changes at all once the game is in action is the strategy, which AIs will change after a given number of turns. There's 5 triggers for how the AI picks a strategy: turn, victory condition, at war, tech age and personality. You can't check 'have I met someone', or 'do I have this many colonies' or 'have I bumped into some pirates'. The AI will always pick the first strategy in the list which fulfills all the valid triggers, and ignore any others which also fulfill all the triggers. This means that we can't actually tell it to anticipate a war - it will only react once it's IN a war.
The AI's early strategies in vanilla already have strong negative weight on military techs, so it generally avoids them til turn 25, and then doesn't have much bonus weight to them til turn 150ish. Marigoldran plays against Godlike AIs, so he's probably just seeing a combination of the ones that that AI gets for free at that level, and the very, very, very occasional random roll that lands military.