First of all, in the case of the 2 weeks notice it would be assumed in that case that the employee decides to “move on” to another company or opportunity elsewhere and that there is no job performance issue between employee and company and likely there would be no negative impacts to company operations or morale. In contrast, the case of being fired of laid off a worker may potentially carry out some kind of sabotage within the workplace or by simply being present in the workplace the employee could bring down company morale because naturally people talk and you would likely tell other coworkers about your leaving and that would put a chill into them in regards to their own job security.
Now here I’ve only covered two basic scenarios and I’m sure that you can imagine or have experienced some variation that isn’t what I described. The point is that the boss or HR person has a responsibility and an interest in the optimal running of the company and if an employee can profitably contribute in the workplace until a future agreed date then most empires would go that way after all if the employee does a good job there’s no point in ending their work sooner than later after all the employee is already trained and could perhaps train their replacement before they leave. This would not necessarily be the case if the employee was not a good worker and was being fired for cause or maybe is hopeless in learning the required skills