So the question would be better addressed if you look at the situation of these specific companies and their respective market situation. Maybe the layoffs happened because it was predictable that no additional workforce was needed in the near future. Sure, maybe the outlook changed now, but I guess the lessened salary costs are attractive for them too.
I would guess they also look at how competitors behave. Apart from the engineering challenge there is little intelligence behind it, it is like Russians building a space shuttle because the Americans were building one.
I believe these hire/fire periods follow a certain cycle that maybe isn't too much tied up with inflation and growth estimates. I suspect we will see more hiring again in 2023. Hopefully more in the civilian sector than the military one.