St Johnstone capitalised on some hesitant Aberdeen defending as two goals in three second-half minutes sealed a 3-1 victory at McDiarmid Park.