Substitute Valentin Stocker scored a late winner as Switzerland beat Hungary 3-2 in Budapest to make it back-to-back qualifying victories.