The structure of leaves lets gases diffuse in and out of cells
Carbon dioxide diffuses into the air spaces within the leaf, then it diffuses into the cells where photosynthesis happens. The leaf's structure is adapted so that this can happen easily
The underneath of the leaf is an exchange surface. It's covered in little holes called stomata which the carbon dioxide diffuses in through
Oxygen and water vapour also diffuse out through the stomata.
The size of the stomata is controlled by guard cells. These close the stomata if the plant is losing water faster than it is being replaced by the roots. Without these guard cells the plant would soon wilt.
The flattened shape of the leaf increases the area of this exchange surface so that it's more effective
The walls of the cells inside the leaf form another exchange surface. The air spaces inside the leaf increase the area of this surface so there's more chance for carbon dioxide to get into the cells.
The water vapour evaporates from the cells inside the leaf. Then is escapes by diffusion because there's a lot of it inside the leaf and less of it in the air outside.