During initial attach, MME fetches UE's subscription profile from HSS. In case of roaming, when attach request receives at roaming network MME, it fetches UE's subscription profile from its home network HSS. After getting subscription profile, MME decides whether it has to use its own network (visited network) PGW or UE's home network PGW. This decision is taken based on subscription (static IP or dynamic IP).
If user has subscribed for static IP then MME at visited network will be using PGW of UE's home network otherwise it will use its own network PGW.
In essence, selection of PGW depends on UE's subscription details.