The question asks for the number of M&M bags and the number of Hershey bars. It is often convenient to assign variables to the things you are asked to find. We can let m and h represent the number of bags of M&Ms and the number of Hershey bars respectively.
The problem statement gives you two relations regarding these variables. One relation involves the associated cost. If each M&M bag costs $3.00, then 3.00m could represent the total cost of all the bags purchased. Likewise the cost of Hershey bars purchased will be 2.00h. Their total cost is given as $59, so you have that relation:
... 3.00m + 2.00h = 59.00
The problem statement also tells you the total number of items purchased was 24. So, you have that relation:
... m + h = 24
You can solve this system of equations in any of the ways you were taught. If you use substitution, the working out might look like this.

Ms. Smith bought 11 bags of M&Ms and 13 Hershey bars.