Thinking more about this new announcement, I am of the opinion that people who join an employer under certain criteria and fulfill these criteria, should be given a chance to adapt to new rules when something changes, before they are dismissed. They joined in good faith and also have undergone training and education for military roles, which is expensive for the military to do. Their roles would need to be refilled by new recruits who first have to be trained again, another cost.
So either they align with the new rules or, if that is not possible, should have a chance at a new role within the military, also to use their experience which they have gained so far. That would cause retraining costs, as above, though and costs for their replacement in the combat roles.
The gain for the military would be to have fewer people who need extra medication in safety-critical roles, and more headspace because no more tripping over pronouns, and more safety and dignity especially for women.
A side aspect is the role for soldiers returning from combat who are permanently injured / have PTSD and will not be active combattants anymore, as they should be offered non-deployment jobs, too, if they want them. So as others pointed out, there might not be enough jobs overall for everyone.
However, nominated defense secretary Hegseth also wants to remove women from combat roles. So we have to be careful of whether this is a two-step process. As mentioned by PP, women have fought for decades and probably in historic times, too, only often their contribution was swept under the carpet. I believe women in combat and command roles are also very important because they might place more emphasis on protecting the civilian population with their decisions, seeing as often women make up the majority of that civilian population in war times.