The place to begin thinking about this question is to understand the foundational question of what a "writ" is.
A "writ" is a court order directed at another government official, often, sometimes, a government official who isn't even a party to the case, although sometimes the government official is a party to the case.
A writ of mandamus, is a writ directing a government official to carry out a non-discretionary duty.
An injunction is a court order (not necessarily a writ, although some writs are injunctions, indeed writs are usually a subset of injunctions directed at government officials) which directs a person who is a party to lawsuit, or is contractually or organizationally connected to a party to a lawsuit, to take some sort of action or to refrain from taking some sort of action. Most injunctions are not writs.
The usual remedy if a government official does not obey a writ of mandamus or an injunction is to hold that government official in contempt of court, for example, by personally fining or incarcerating that government official.
How did judicial review develop out of this two writs, exactly?
As a footnote, there are a lot more than two kinds of writs. There are actually maybe half a dozen in regular use, including writs of prohibition (ordering public officials not to do something), writs of certiorari (reviewing discretionary decisions of lower courts and public officials acting in a quasi-judicial role on legal issues), writ of quo warranto (resolving disputes over who holds a public office), writs of attachment (ordering public officials to seize property, especially tangible personal property, to satisfy a money judgment), writs of restitution (ordering a public official to restore possession of real property to someone), writs of execution (ordering public officials to carry out court orders, usually money judgments rather than death penalty orders), writs of assistance (authorizing a public official to trespass on someone's real property in furtherance of some other purpose), and writs of garnishment (authorizing a public official to seize property owned by a money judgment debtor from someone other than the debtor who is in the possession of the debtor's property like a bank or an employer, if they don't comply in turning over that property), and more.
The modern trend is to replace historic common law writs (which are statutorily authorized in the federal system by the All Writs Act which was one of the first acts passed by the first Congress in 1789), with court rules with plain English names that confer equivalent authority.
To appreciate what a big deal this is, you need to compare the powers of common law legal system judges to the powers of civil law legal system judges such as the ordinary court judges of France, Spain and Germany.
Civil law judges don't have the contempt of court power. They have some resources to enforce their orders, but no tool nearly so powerful or sweeping.
The ordinary courts of civil law countries, unlike those of common law countries, historically have not had the power to rule on questions of "public law" (i.e. disputes involving governmental agencies and officials apart from issuing sentences in criminal cases). Instead, civil law judges in ordinary civil law courts only have jurisdiction over disputes between private parties and over criminal prosecutions. Separate public law tribunals, sometimes called administrative courts and sometimes called something different, handle public law cases (in France, for example, these cases are handled by the "Council of State" which is run by elite civil servants whose upper levels are populated almost entirely by graduates of France's top university).
In the 20th century, when Europeans (and people in other civil law countries) started to imitate the vibrant U.S. constitutional individual rights jurisprudence mostly arising under the federal Bill of Rights, the bureaucratic inertia of centuries was too great to copy the common law model, so instead, civil law countries instead tended to create stand alone "constitutional courts" outside the ordinary court system, with the authority to enforce their newly enacted human rights protections in their national constitutions instead, handling this special and important subset of public law in the same manner that non-constitutional public law questions had always been handled by a separate set of courts in those countries.
This divide emerged because in post-Norman invasion England, judges are successors to feudal aristocrats who personally held courts and resolved disputes between their subjects and had life and death power over then and a direct command authority over all public officials. Professional judges in the common law system were originally courtiers who volunteered to substitute for the aristocrats themselves in doing this job (which required lots of skill and was more boring than training to sword fight and ride horses and commanding soldiers), who as agents of local lords had all of the authority and power of the lords themselves for whom they were trusted inner circle advisors.
The core contempt power is actually the power to summarily fine or incarcerate someone who disrespects the judge or aristocrats in the presence in open court, without a trial, which was broadened to include include defiance of and disrespect for the court outside of its presence by disobeying its orders. In contrast, if someone is disrespectful or disorderly in a civil law court, the judge calls the cops just the way anyone who wasn't a judge would if someone got out of control in their office or board meeting. Civil law judges, following the classical Roman tradition, were appointed specialized civil servants, rather than delegates of aristocrats, from the state in continental Europe and in countries that followed the continental European model. (In Rome, most cases were decide by judges who had a role closer to modern private arbitrators than today's judges.)
As courts in England became more bureaucratized and divorced from the aristocratic model, the ordinary English courts drifted in the direction of civil law courts, but then, the English Chancellor (an official most similar in role to the Secretary of Treasury in the U.S.) who was a top cabinet level official of the Prime Minister and the King, developed a parallel set of courts that rather than being public law courts, handled what was called "equity", basically providing legal remedies in cases where the bureaucratic civil law style courts of law in 18th and 19th century century England couldn't do anything since they had only narrow jurisdiction. The courts of chancery, a.k.a. judges of courts of equity in England, led by an aristocratic high cabinet official, took over the tradition of contempt of court authority previously wielded by aristocrats holding court over their subjects. And, when England decided to be efficient by merging the courts of law and the courts of equity into one unified system in the 19th century, the judges of the new combined system were granted to combined powers of judges in courts of law and judges in courts of equity, restoring to them the power to issue a wide variety of writs and to hold public officials in contempt of court if they disobeyed, something natural for the top government official holding the purse strings over all other government officials in England.
Now, originally, in England, writs weren't used for the purpose of judicial review of legislation. Under the doctrines of royal absolutism and parliamentary sovereignty, courts in England until very recently, didn't have any authority to invalidate a law. But, rather than creating a separate set of public law courts, the English gave the ordinary judges of their ordinary courts the authority to force civil servants to obey the laws that Parliament enacted with royal approval.
Once judges are used to bossing around civil servants for not doing their jobs in accordance with the law (which English judges had already been doing for centuries), it becomes second nature, in a complicated governmental system like that of the United States with federalism and the separation of powers, for judges to order state officials not to disregard federal laws that conflict with state laws (under the supremacy clause), which they did on a regular basis starting in the early 1800s, and to order federal officials to disregard federal laws that conflicted with the U.S. Constitution, which they did much less frequently until after World War II.
The other piece of the story that is important to understand, is that there were no direct appeals of federal criminal convictions until the late 1800s when the intermediate federal courts of appeal were created, and this was also true in many states. Prior to that, the only form of judicial review of a criminal conviction was a writ of habeas corpus, which is why this takes such a prominent role as a protected writ in the federal constitution even before the Bill of Rights was adopted.
The general rule was that a writ of habeas corpus should be denied any time that someone was incarcerated pursuant to a criminal conviction of a court with jurisdiction, or was in the process of facing trial on a criminal charge by a court with jurisdiction. But in the absence of any other form of judicial review of wrongful criminal convictions except the executive branch pardon power, courts read their mandate to find that criminal convictions were jurisdictionally deficient expansively to cover a multitude of procedural irregularities in a criminal conviction.
So, even the review of law enforcement discretion now handled (a form of bossing around government employees) mostly through direct appeals of criminal convictions and pre-trial appeals of key rulings by trial courts in criminal cases, was historically done through writ practice.
I personally learned this piecemeal, but one of the leading histories of law in the United States is A History of American Law by Lawrence M. Friedman.