Before digging into comparative advantage, it's important to first understand specialization, and how that determines what goods a society produces.
The Isle of Crammer Nation and the Archipelago of Economicals are known for their incredible caffeinated drinks. While both societies utilize the same resources (a.k.a. capital) to make their energy drinks and coffee, they each have their respective production secrets to producing each good.
The Archipelago of Economicals is known to have one of the most efficient and effective production techniques for creating energy drinks, while the Isle of Crammer Nation has spent more time crafting their coffee production capabilities.
We can conceptualize this as...
Specialization is the limiting of ones work to a particular area, typically the area in which is it most beneficial to produce.
Given the same resources, see the below table for each society's production capabilities:
|Isle of Crammer Nation||100||100|
|Archipelago of Economicals||50||200|
As we can see, the Isle of Crammer Nation is better at producing coffee and the Archipelago of Economicals is better at producing energy drinks. This would result in the two trading with one-another so each respective society doesn't need to waste time producing the good that they're specialized in.
Specialization and trade generates gains for societies. It enables societies to focus on what they're good at, and not waste resources on goods or services that other societies can do more efficiently.
Identifying absolute advantage
To identify who has the absolute advantage for what product, imagine that no trade was occurring. All it comes down to is who can produce more units of a given product with the same resources.