What's the role of 了 in this sentence: 你要是喜欢我就给你买了
I think the key is the usage of 了. In my opinion, 了 here works like a result complement,  which indicates the status changed. 

Semantically, they(with or without 了) denote the same meaning.

我买 vs 我买了: 

我买 is like saying "I will buy" in English.

我买了 is like "I will have/get it bought. The status changed from not bought to bought.

Another example is 我走 vs 我走了. 我走 is I am going. 我走了 is I will be gone. The status changed from staying here to be gone.

Hope this could help you out.