Thousands of military homes across the UK will be modernised, refurbished or rebuilt over the next decade under a £9bn government plan to improve defence housing.