What are some sectors in which nations benefit from collaborating with other nations? For instance, if a nation is an ally (diplomatic/trade) with another nation, the average payoff each nation gets is higher than the payoff they would gain individually?

For instance, comparing to individuals and chat applications, if one user uses chat app A, and another uses B, they can't communicate. But they can communicate with all friends who use the same chat app. The payoff is directly proportional to the number of friends which use the same application.
Nations can benefit from each other in all three of the broad sectors.

Collaboration in the primary sector (Involving raw materials, fishing, agriculture and mining) can lead to more sustainable extraction of resources. For example Nation A can choose to import Resource Y from Nation B rather than exhausting their own source. Nation A gains Resource Y and Nation B gets money.

Outsourcing is the most obvious example of collaboration in the secondary sector, Australian companies may outsource manufacturing work to Bangladesh, this is beneficial to both nations as money is going to Bangladesh and goods are going to Australia.

The tertiary sector involves providing services to consumers. One example of this could be tourism related services, if a tourist from overseas uses one of these tourist related services, the country they are visiting would receive money in exchange for the service, and the tourist would have their experience improved in some way. This example is small scale but when you consider how many people travel around the world it builds up.