This is called Euclid's Lemma.
If $p$ is a prime and $p|ab$ then either $p|a$ or $p|b$.
I won't prove this but I think of it like this. If $p$ is prime it can't be split up, so it goes into $ab$ as a whole. So all of it goes into $a$ or all of it goes into $b$. [... or both....$p$ dividing both $a$ and $b$ is always an option... but if $p$ goes into neither then it won't go into $ab$...]
(That's not a proof and makes a lot of assumptions and has a lot of handwaving but that is the general idea. This should be a common sense notion.)
Okay, so if $5$ which is prime, divides into $7b^2$ then either $5|7$ or $5|b^2$. Well $5|7$ just ain't true. So $5|b^2$. But if $5|\color{blue}b\cdot \color{red}b$ then "either $5|\color{blue}b$ or .... $5|\color{red}b$"..... which means $5|b$.
And that's that.
=====
Alternatively:
Supposed $b = 5k + r$ where $r = 0,1,2,3,4$.
Then $7b^2 = 7\cdot (5k+r)^2 = 7*(25k^2 + 10kr + r^2)= 175k^2 + 70kr + 7r^2$.
Now $5|7b^2$ and $5|175k^2 + 70kr$ so $5|7r^2$. But $r^2 = 0,1,4,9,16$ and $7r^2 = 0,7,28, 63,112$. But the only one that is divisible by $5$ is $0$.
So $r=0$. And $b=5k$ and $5|b$.
======
Okay, a proof of Euclid's Lemma:
If you have two positive integers $a, b ; a < b$ you can find the greatest common divisor in the following method call Euclid's algorithm.
$b = k*a + r$ are for some $r$ and $k$ where $0\le r < a$. ($r$ is just the remainder.) If $r =0$ we are done $a|b$. Other wise notice that $d$ is a common divisor of $a$ and $b$ then $d$ must also divide $r$ because $r = b-k*a = d(\frac bd + k*\frac ad)$.
Now we do the same thing for $a= j*r + s$ and if $s=0$ we are done as $r|a$ and so $r|b$. (Because $b= k*\frac ar\times r + r$). But if $s\ne 0$ and $d$ is a common divisor of $a$ and $b$ and therefore of $r$ then $d$ is also a divisor of $s$ for the same reason as above.
And we keep doing this. Each time we get a smaller and smaller remainder so there must be a point where it ends and we get a remainder of $0$. The last remainder we get before that is the greatest common divisor of $a$ and $b$ because any common divisor of $a,b$ must divide into the final remainder so the final remainder is larger than any common divisor and is a common divisor. So it is the greatest common divisor.
Example. To find $\gcd(15,36)$ we do:
$36 = 2*15 + 6$
$15 = 2*6 + 3$
$6 = 2*3 + 0$. So the last remainder was $3$ and $3=\gcd(15,36)$.
No if we combine all the steps together when we got $\gcd(a,b)$ as the final remainder we can combine all the steps to get an equation that there are integers (not necessarily positiv) $m,n$ where $ma + nb = \gcd(a,b)$.
For example $3 = 15- 2*6$ but $6 = 36 -2*15$ so $3 = 15 - 2(36 - 2*15) = 5*15 -2*36$.
This is called Bezout's Lemma: If $\gcd(a,b) = d$ then there are integers $m,n$ so that $ma + nb = d$.
Now let's prove Euclid's Lemma:
Suppose $p|ab$. If $p|a$ we are done. SO lets assume $p\not \mid a$. As $p$ is prime that means $\gcd(p,a) = 1$.
So by Bezout's Lemma, there are $m,n$ so that $mp + na = 1$.
So $mpb + nab = b$ so $p(mb) = b-(ab)n$. So $p|b-(ab)n$. But $p|ab$ so $p|(ab)n$. So $p|[b-(ab)n] + (ab)n$. So $p|b$.
And that prove's Euclid's Lemma: If $p|ab$ then either $p|a$, but if it doesn't then $p|b$.