In a regular category: How can you construct $m^R$ (second isomorphism theorem)? The title is bit vague because I don't know how the object I want to find is called.
In universal algebra we have the following: Let $A$ be an algebra with subalgebra $M$ and congruence relation $R$. Then let $M^R := \bigcup_{x\in M} [x]_R$. This structure occurs in the second isomorphism theorem (that's the $MN$ in the group-theoretic version: "$\frac{MN}{N} \cong \frac{M}{M\cap N}$", where $N$ corresponds to $R$).
Speaking more categorically: Let $\mathcal A$ be a regular category with object $A$ and an (internal) congruence $R$ on $A$. Let $m : M \to A$ be a suboject of (i.e. a mono into) $A$. I want to find a subobject $m^R : M^R  \to A$ of $A$, which has the same role as the one in the above paragraph. Obviously I can't "union equivalence classes" (at least I don't see how). There should be a morphism $M\to M^R$ that gives you $m$ if you compose with $m^R$ ($M^R$ is a subalgebra of $M$) and $m^R$ should have something to do with $R$ and / or the quotient $e_R : A\to A/R$.

How can I construct $m^R$ categorically in this setting (if possible)?

 A: Let $q : A \to A/R$ be the quotient (i.e. the coequalizer of the projections of $R$). Now let $n : N \to A/R$ be a monomorphism and $e: M\to N$ be a regular epimorphism such that $q\circ m = n \circ e$ (i.e. $n$ is the regular image of $m$ along $q$). Now let $(M^R,m^R,e')$, where $M^R$ is an object and $m^R : M^R\to A$ and $e': M^R \to N$ are morphisms, be the pullback of $n : N\to A/R$ and $q : A\to A/R$. The morphism $m^R$ is a monomorphism (being the pullback of $n$) and $m$ factors through it as desired (via the universal property of the pullback).
For a variety, we can choose $N=q(M)$ and $M^R = q^{-1}(N)$ (since regular images and pullbacks are only defined up to isomorphism).
We then have that $$M^R= q^{-1}(q(M)) = \{a \in A\,|\, \exists x \in M\, q(a)=q(x)\}= \{a \in A\,|\,\exists x \in M\, a \in [x]_R\} = \bigcup_{x \in M} [x]_R$$
as desired.
The above can also be understood as follows. The morphism $q: A \to A/R$ determines a Galois connection between the posets of subobjects $\text{Sub}(A)$ and $\text{Sub}(A/R)$ with left adjoint $q_*$ sending a subobject to its image along $q$ and right adjoint $q^*$ determined by pulling back. In this language $m^R : M^R \to A$ is the closure of $m : M \to A$ with respect to the closure operator $q^*q_*$.
