Talk:Alternate-Self Learning/@comment-24619160-20151001060331/@comment-5739199-20151022004928

"During the Fate scenario, he slowly learns of it on his own by training with Rin and following Archer's advice: "If you can't defeat it, then imagine what can", while in the Unlimited Blade Works scenario, he learns of it through extensive contact with Archer."

and

"Two versions of the same person on the same time axis can have similar effects, such as with Shirou Emiya absorbing his future self's memories and skills by just having contact with him."

Source: http://typemoon.wikia.com/

He learns UBW gradually by interacting with Archer.

Also, you are wrong that Shirou always had UBW even before meeting Kiritsugu. When Kiritsugu implanted Avalon in Shirou, his magical affinity was changed to "sword", thus him gaining Unlimited Blade Works.