The simple legal answer is that the President has this power because the law gives it to them.
Historically, the right of the head of state to grant pardons is a legacy of autocratic monarchical rule: this was a power that kings and queens had over their subjects. In France, this power ended with the monarchy during the French revolution but was reinstated by Napoleon, himself an autocratic monarch, and it has remained in the various incarnations of the French legal system ever since. Here is an examination of the concept in various jurisdictions.
The concept of separation of powers is a much more recent concept. In particular, the tripartite separation into administrative, judicial and legislative power can be traced to Montesquieu in his The Spirit of the Laws in 1748. This Enlightenment point of view crept into many political systems, however, the specific expression of it reached full flower in the establishment of the United States. It is worth noting, that pardons at both state and Federal level are part of US law vesting in the Governor (or some other member of the executive) and the President respectively.
The tripartite separation is supposed to provide checks and balances with each arm of government serving to limit the power of the other two. In this context, it is perfectly reconcilable that the executive branch should have the power to intervene and correct "mistakes" made by the judiciary just as the legislative branch does by being able to change the law in the light of judicial interpretation of existing law. In effect, the executive can correct "mistakes" in individual cases looking backwards and the legislature can correct "mistakes" in general going forward (the do in fact have the power to make laws retrospective [backwards looking] and specific but they tend not to do so).