Two devices on a main supply line to Ukraine were intended to derail passing trains but failed, the prime minister said, and the two suspects fled the country.