If a country wants to build a credible military, it must spend consistently in the long term. Short term spikes in defence spending may not be sustainable and may not build capability in the long run. A few more points to add:
1. Buying hardware is only a fraction of the cost in building military capability. After getting the hardware, there is a need to train the people to operate it properly (manpower and training cost), otherwise it cannot be put to use effectively. Then, there is the need to maintain it in operational condition (maintenance cost). This is no small matter due to the need to ensure a constant supply of spare parts, especially for military hardware that is no longer in production. Than, there is also operational cost, which is the cost incurred when military hardware and personnel are deployed for real operations (including surveillance operations. In short, having the money to buy the hardware, but not having the money to pay for the personnel to operate it does not bring new capability.
2. Due to the above issues, long term, consistent spending is required as military capability is built up over time (measured in years, not months). Pilots don't become top-notch after a few hours behind the stick of a multi-role fighter. Neither do sailors become top-notch war-fighters without a lot of training. A feast of famine approach will not build sustainable military capability in the long run.
3. Hence, a country needs a consistent position on its defence needs. If the defence budget is subjected to politicking where different political parties prioritise it differently when they form the government, than don't expect a consistent build-up in military capability.