Out of the four equations that you have, you need to find $\Delta H^\circ_\mathrm f$ of $\ce{MgO}$, or rather, the $\Delta H$ value of the reaction
$$\ce{Mg(s) + 1/2O2(g) -> MgO(s)} \tag{1} \label{1}$$
Why is this? This is because of the definition of heat of formation is as follows:
Standard heat of formation of a compound is the change of enthalpy during the formation of 1 mole of the substance from its constituent elements, with all substances in their standard states. (emphasis mine)
In the above equation, the elements are in their standard states and they are used to form one mole of $\ce{MgO}$.
Onto the solution:
We need to apply Hess's law of constant heat summation, which states that:
The change of enthalpy in a chemical reaction (i.e. the heat of reaction at constant pressure) is independent of the pathway between the initial and final states.
In other words, if a chemical change takes place by several different routes, the overall enthalpy change is the same, regardless of the route by which the chemical change occurs (provided the initial and final condition are the same).
Therefore if we can write any equation in terms of two or more other reactions, the change in enthalpy of the first reaction can be written as a linear combination of enthalpies of said reactions.
Here the other equations for which we know the enthalpies are:
\begin{align}
\ce{Mg(s) + 2HCl(aq) &-> MgCl2(aq) + H2(g)} \tag{2} \label{2}\\
\ce{MgO(s) + 2HCl(aq) &-> MgCl2(aq) + H2O(l)} \tag{3} \label{3}\\
\ce{H2(g) + 1/2O2(g) &-> H2O(l)} \tag{4} \label{4}
\end{align}
Now, in order to proceed we need to write ($\ref{1}$) in terms of a linear combination of ($\ref{2}$), $(\ref{3})$ and $(\ref{4})$.
Finding the possible combination using observation (Method 1)
We need to notice that in our final reaction equation ($\ref{1}$), we need to have an $\ce{MgO}$ on the right and the only equation where an $\ce{MgO}$ molecule exists is in $(\ref{3})$, similarly, we observe that only $(\ref{2})$ has an $\ce{Mg}$ molecule and therefore, we can say that the final combination needs to have $(1) = (2) - (3) + x(4)$.
Substituting the equations and solving for $x$, we get x = 1, (which could have also been guessed using the above mentioned method).
Therefore our final linear combination is as follows:
$$\Delta H^\circ_\mathrm f = \Delta H^\circ_2 + \Delta H^\circ_4 - \Delta H^\circ_3$$
Finding the answer through applying math (Method 2)
We write
$$(1) = x(2) + y(3) + z(4)$$
After this, we compare the left hand side and right hand side which should satisfy the conservation of mass.
Therefore:
\begin{align}
\ce{Mg(s) + 1/2O2(g) &-> MgO(s)} \tag{LHS}\\
\ce{xMg + yMgO + (2x + 2y)HCl + zH2 + z/2O2 &-> (x + y)MgCl2 + (y+z)H2O + xH2} \tag{RHS}
\end{align}
Comparing co-efficient on both sides, we get:
\begin{align}
x &= 1 \\
y &= -1 \\
x + y &= 0 \\
z &= x \\
z &= 1\\
\end{align}
Either way, we get the same combination for Hess' Law and that is:
$$\Delta H^\circ_\mathrm f = \Delta H^\circ_2 + \Delta H^\circ_4 - \Delta H^\circ_3$$