How did "itch" come to be used to mean "scratch" as in "I had to itch my leg"?

You note the Germanic origins, and in German, (https://en.bab.la/dictionary/german-english/kratzen) You will note that jucken and krazten are both used.

That said, it is likely to be a transitional effect in which an assumed meaning is attached to the word.

The earliest recorded use (Oxford English Dictionary) is in the meaning of:

1. intransitive. To have or feel irritation of the skin, such as causes an inclination to scratch the part affected: said of the part; also of the person affected. Also impersonal, it itches, there is an itching.

α.

c1000 Sax. Leechd. III. 50 Wið giccendre wombe.

[...]

1875 B. Jowett in tr. Plato Dialogues (ed. 2) IV. 17 Socrates dilates on the pleasures of itching and scratching.

1897 T. C. Allbutt et al. Syst. Med. III. 343 The cracks often itch in a most troublesome way.

An additional meaning appeared later

3. transitive. To cause to itch. Also reflexive and figurative.

1577 R. Stanyhurst Hist. Irelande iii. 90/2 in R. Holinshed Chron. I It may be, that..I shal be able like a flesh worme to itch the bodie of his Kingdome, and force him to scratch deepelie.

[...]

1951 L. MacNeice tr. J. W. von Goethe Faust ii. i. 171 The dice already itch me in my pocket.

1954 S. Beckett Waiting for Godot ii. 46 Then I can keep it [sc. a hat]. Mine irked me... How shall I say?..It itched me.

In the quotes of 1951 and 1954, you can see the possible understanding of "to itch" as "to irritate" or "to scratch." It is probably this that led to the confusion, and basic misuse.

We see similar misuses become used in "lend" and "borrow" and "fulsome" and "fullest"