You have \begin{align} M=a\log_{10}S+b \end{align} Then, from the given values you have \begin{align} 7=a\log_{10}(4.47\times10^{25})+b\tag1 \end{align} and \begin{align} 7.5=a\log_{10}(2\times10^{27})+b\tag2 \end{align} Subtract $(1)$ from $(2)$ yield \begin{align} 7.5-7&=a\log_{10}(2\times10^{27})+b-(a\log_{10}(4.47\times10^{25})+b)\\\ 0.5&=a\log_{10}(2\times10^{27})-a\log_{10}(4.47\times10^{25})\\\ 0.5&=a(\log_{10}(2\times10^{27})-\log_{10}(4.47\times10^{25}))\\\ 0.5&=a\log_{10}\left(\frac{2\times10^{27}}{4.47\times10^{25}}\right)\\\ a&=\frac{0.5}{\log_{10}\left(\frac{2\times10^{27}}{4.47\times10^{25}}\right)} \end{align} The value of $b$ can be obtained by substituting $a$ to $(1)$ or $(2)$.
* * *
\begin{align} 7&=\frac{0.5}{\log_{10}\left(\frac{2\times10^{27}}{4.47\times10^{25}}\right)}\log_{10}(4.47\times10^{25})+b\\\ b&=7-\frac{0.5\log_{10}(4.47\times10^{25})}{\log_{10}\left(\frac{2\times10^{27}}{4.47\times10^{25}}\right)} \end{align}