The alternative was far worse than Jeremy Corbyn. Boris Johnson was not exactly a safe pair of hands protecting the UK’s domestic security. Boris Johnson’s government refused to release the Parliamentary Intelligence and Security Committee Report which analysed Russian meddling in the UK Brexit referendum.
Under the Conservative government, army personnel has fallen from 102,000 to less than 74,000. The Royal Air Force (RAF) and the Navy have undergone similar cuts. Additionally, military staff have had to settle with seven years of pay increases below the national inflation rate. 
There is also evidence to suggest that voters see Labour as stronger than the Conservatives on national security matters. Labour doubled its vote share in 2017 in places like Aldershot, which have a large military presence, even with Jeremy Corbyn as the party leader. This exposes the invalidity of arguments which suggest Labour lost the election due to the public perception that Jeremy Corbyn couldn’t be trusted on national security.