Does it mean that Harut and Marut could teach people magic if they were asked to by the people during that time?
Ibn 'Abbas (May Allah be pleased with him) said: they used to warn anyone who came to them to learn magic and say to him: {We are only for trial, so disbelieve not (by learning this magic from us)}, that they knew what is good, bad, belief and disbelief and thus they knew that magic is of disbelief. Ibn 'Abbas (May Allah be pleased with him) continued: if they could not dissuade him, they told him to go to such and such place. There he could find Satan who teaches him. The same time one is taught magic, his belief (symbolized as light) gets out of his body and he could see it flying away in the sky. Upon this, he would say: woe to me! In addition: Al Hasan Al-Basri said: the two angels were sent with magic to teach the people as a test for them and Allah took their covenant that they do not teach anybody{till they had said, "We are only for trial, so disbelieve not (by learning this magic from us)"}. (Narrated by Ibn Abu Hatim)
Narrated Qatadah: The Covenant was taken from them that they don't teach anyone till they say: {We are only for trial, so disbelieve not (by learning this magic from us)}. Moreover, As-Sadiy said: they used to warn anyone who came to them to learn magic and say to him: {We are only for trial, so disbelieve not (by learning this magic from us)}. But, if he insisted, they would say: Go to that pile of ashes and "squeeze the lemon thereon". If the man goes and does what he was ordered, he would see a light coming out of that ashes and flies till it reaches the sky -verily, this is belief. Instead, there would come a black object that would look like smokes and enters his ears and the whole of his body -verily, this is Allah's Wrath. After that, the man tells them of what happened and they consequently teaches him magic. This is the interpretation of Allah's Saying: {But neither of these two (angels) taught anyone (such things) till they had said, "We are only for trial, so disbelieve not (by learning this magic from us)." And from these (angels) people learn that by which they cause separation between man and his wife, but they could not thus harm anyone except by Allah's Leave.And they learn that which harms them and profits them not. And indeed they knew that the buyers of it (magic) would have no share in the Hereafter. And how bad indeed was that for which they sold their own selves, if they but knew}.
Excerpted From Stories of Quran by Ibn Kathir
How do they become a trial if people can't learn magic from them?
The answer lies in the same verse you quoted:
And from these (angels) people learn that by which they cause separation between man and his wife, but they could not thus harm anyone except by Allah's Leave.
This form of magic still exists to this very day...