(And even if it does, the fact that the NPV of a project "turned negative" indicates that the value of the company dropped, and the layoffs are only a partial mitigation, which still hurts the perception of the company if the market hadn't discovered and priced in the drop before the company did and reacted with layoffs.)
Another factor is that retained employees that learn of companies layoff frequently become concerned about their own position and the treatment of the workers that were laid off, reducing employee morale. High performers may start looking for another job in order to avoid expected future layoffs.
Then there’s the impact on potential future employees, who will also know about the layoffs. These employees will be aware of recently layoffs and will expect more money from said company who will also have to train the new employee that replaced the one they laid off before.
Finally, you have the impact on potential customers or existing customers. Some customers have relationships with employees that are laid off, and this can be jarring. The customers may become concerned about the liability of the company or the management of the company, potentially moving all our part of their business to another firm.
All of these effects are not typically beneficial to the company or it’s shareholders.
Layoffs are a signal to markets of struggles, and firms absolutely do, in practice, need to justify them (and their scale and focus) to avoid the risk of a self-fulfilling market perception that they signal a problems that they do not fully resolve. (If there is already a problem narrative, much of the justification is obvious, and the firm just needs to cover explaining how the layoffs address the problem.)