Heat produced when magnesium is reacted with acid
It can help to imagine the experimental setup.

Imagine a thermally insulated reaction container, let's call it calorimeter, that is filled with 50 ml 1 M $\ce{HCl}$ ( = a solution of hydrogen chloride gas in water).

We have to measure a temperature change ($\Delta{} T$), that comes from an exothermic reaction. Where would we best measure this temperature change? Our reaction medium apparently is a good choice. Therefore, there's most likely a thermometer (insulated from the outside) in good thermal contact with the water.

Now we let the magnesium strip fall into the reaction medium (using some clever mechanic) while our calorimeter is closed), let it react and measure the temperature change until the temperature reaches some final (maximum) value.

As you wrote, the temperature change ($ \Delta{} T$) is +7 °C.

I don't see that an initial temperature was given, but that's not important. We have the $ \Delta{} T$.

Now we need a specific factor that correlates the heat liberated in the reaction with the temperature change in a specific medium.

Here, the specific heat capacity of water comes into play.

There you go.