Defense secretary tells service members their midterms ballots will be counted after the administration’s failed legal battle to overhaul elections