Replace the informations you don't know with letters.
x = number of bags
y = number of sandwiches
7x + 3y = 22
3x + y = 8
Then solve the equations.
First, isolate the y in the second one like this :
y = 8 - 3x
then replace the y in the first equation with its worth from the second equation :
7x + 3(8 - 3x) = 22
solve for x, then replace the value in the equations to get the value of y