The first equation shows two terms can be combine as follow: 8pq-3pq= (8-3)pq by applying common factoring. Then, because 8-3=5, it can be expressed as 5pq.
In the second equation, we have only two terms that can be factored by combining the terms that share the same factor (which is m). Then, 2m-3m+4 can be expressed like m(2-3)+4. Because (2-3)=-1 and because the order of the sum does not affect the result, the result is 4-m.