The 1st Amendment states
Congress shall make no law ... abridging the freedom of speech, or of the press
So how can libel law be constitutional?
There's an interesting philosophical debate you can have. By the plain text of the First Amendment, it protects libel.
Aside: Yes, the First Amendment does apply to libel cases. A libel case, like all lawsuits, involves the government's judicial branch using its coercive power to make you pay money as a result of your speech, based on a law requiring you to pay money for certain kinds of speech. Tort law is not optional; a libel case isn't "you promised not to say bad things and then said bad things," it's the government saying "what you did is bad, now pay the person you hurt because of your speech."
The idea that "you can say it, you just have to face the consequences" isn't enough and hasn't been for quite a while now. Traditionally, the main point of freedom of speech was that a court couldn't stop you from saying something, but could only seek to punish you after the fact (and for that you get a jury, a public hearing, etc.) But more recently, courts realized that subsequent punishment had similar effects to prior restraint. If you're going to be punished for some kind of speech, you're going to steer clear of saying anything a jury might think is that kind of speech.
Libel law is heavily influenced by the First Amendment, and has been for over 40 years.
The First Amendment looks like it protects libel, but it also looks like it should protect your right to reprint any book you want. It also looks like it should protect your right to tell someone "go and murder this person." It also looks like it should protect your right to say whatever you want in court, whether or not it's true. It also looks like it should protect your right to falsely shout "fire" in a crowded hall, with the intent to cause a stampede (this isn't just a turn of phrase, there was an actual incident in which 73 people were killed which is believed to have started when someone falsely shouted that there was a fire). It also looks like it should protect your right to post a sign saying "There is a bomb at this elementary school."
Yet the Constitution explicitly sanctions copyright, and no one would seriously conclude that Congress may not protect the integrity of the judicial process by punishing perjury. Ordering a hit, making bomb threats, intentionally causing panics -- the fact that speech is a key part of these can't mean that the government isn't allowed to criminalize them. You cannot run a civilized society in which death threats are legal.
So, the courts interpret. Language in the Constitution that appears absolute is understood to have implied exceptions. The people writing the document were well aware that perjury was generally a crime. The same Congress that proposed the First Amendment passed a law criminalizing perjury. Sure, you're punishing someone based on their speech, but it's clearly not meant to be protected. You can't run a court system without perjury laws, and its absence from the First Amendment doesn't mean that the First Amendment thereby upended this basic principle.
The courts have identified a number of kinds of speech that, by longstanding practice, are not protected. Intellectual property violations are one. Obscenity is another. So are threats. So is "speech integral to criminal conduct" (e.g. "what'll it be, your money or your life?") And so is defamation. The text of the First Amendment may not exclude it, but courts have uniformly held that it's not something the amendment was ever meant to protect.
The First Amendment does still pose constraints, which are some of the most defendant-friendly in the world (interestingly enough, US law is descended from English law, and English libel law used to be among the most plaintiff-friendly in the world). It's not libel if it's true. It's not libel if it's an opinion (unless it's a statement of fact dressed up as opinion). It's not libel unless you were at least negligent; if it was about a public figure, you have to have known it was false or seriously doubted its truth. But these restrictions leave a core of speech that is and always has been punishable.
They present a brief history history of libel in relation to the First Amendment and then quote a justification for why this punishment is not contrary to the Constitution. (Emphasis mine, and internal citations removed.)
Libel of an individual was a common law crime, and thus criminal in the colonies. Indeed, at common law, truth or good motives was no defense. In the first decades after the adoption of the Constitution, this was changed by judicial decision, statute or constitution in most States, but nowhere was there any suggestion that the crime of libel be abolished. Today, every American jurisdiction -- the forty-eight States, the District of Columbia, Alaska, Hawaii and Puerto Rico -- punish libels directed at individuals.
"There are certain well defined and narrowly limited classes of speech the prevention and punishment of which has never been thought to raise any Constitutional problem. These include the lewd and obscene, the profane, the libelous, and the insulting or 'fighting' words -- those which, by their very utterance, inflict injury or tend to incite an immediate breach of the peace. It has been well observed that such utterances are no essential part of any exposition of ideas, and are of such slight social value as a step to truth that any benefit that may be derived from them is clearly outweighed by the social interest in order and morality." (Quoting from Cantwell v. Connecticut, 310 U.S. 296 (1940))
As I understand it, libel is a civil matter between private parties, and the government's only interest is in providing assistance in resolving the dispute. I don't think the parties pursuing libel suits are typically government entities or officials acting in their official capacities, possibly for exactly the reason you give: it would be unconstitutional.
Another possible justification is that it is not the speech, per se, that is targeted, but the content of the speech. Incitement to commit a crime is illegal, not the speech used as a vehicle for said incitement. Treason is illegal, not the written instruments you used to perpetrate it. Etc.
It can't, according to the dissent in Rosenblatt v. Baer 383 U.S. 75 by Black, Douglas concurring:
The only sure way to protect speech and press against these threats is to recognize that libel laws are abridgments of speech and press, and therefore are barred in both federal and state courts by the First and Fourteenth Amendments. I repeat what I said in the New York Times -- case that "An unconditional right to say what one pleases about public affairs is what I consider to be the minimum guarantee of the First Amendment."
To the extent that the government can use its coercive power to define elements of an offense, render a judgment against you (in civil court) and enforce it, as cpast observes, it is government action.
The apparent contradiction between libel and the 1st Amendment does not exist at all.
In the U.S. you are free to speak. If your speech is libelous, you have to compensate for it.
There are no criminal penalties for libel as there are in some other countries.
There are limits that the Supreme Court has found to the unfettered exercise of free speech. Of relevance, defamation (which is the collective term for libel and slander) is one of those limits. This link lists the major cases on this matter.
While government cannot prohibit defamation, it can make laws that allow those who have been defamed to sue for damages.
So, you are free to speak and you are free to take the consequences if your speech is untruthful and damages someone's reputation (and, for government officials, is made with malice).