It could be the IF..THEN is wrong, or maybe the y-coordinate is misspelled somehow. It could also be a logical problem, like first setting the flag in the first IF, then resetting it in the second one.
You could also try drawing some debug output to the screen, like:
if imagesoverlap(mouse, image1) then text 0, 0, "button1"
if imagesoverlap(mouse, image2) then text 0, 20, "button2"
You could also try drawing some debug output to the screen, like:
if imagesoverlap(mouse, image1) then text 0, 0, "button1"
if imagesoverlap(mouse, image2) then text 0, 20, "button2"