What does 为 do in 鸦片战争后，天津开放为通商口岸?
为 means 变成 / 成为 here.


  (7) 变成，成为 [become]
  
  何遽不为福。——《淮南子·人间训》
  
  不能为祸。
  
  终为忠臣。——《世说新语·自新》
  
  而改为入。——宋· 洪迈《容斋续笔》


The sentence means Tianjin (was) opened and became treaty port.