In the formula the area(A) is perpendicular to the flow current, The length (l) is along the flow of current. Consider an example that will clear you doubt. Consider a hollow cylinder with inner radius 'a' and outer radius 'b' and length 'l' .
Case 1Case 1- Potential difference is applied along the length 'l' of cylinder. Here current flows along the length (l) and area perpendicular to it is $$π (b^2-a^2)$$ $$R = \frac{pl}{π(b^2-a^2)}$$ Case 2
Case 2- Potential is applied across the inner part and outer part of cylinder
Here the the current flows from inner part to outer part of cylinder.
The area perpendicular to current flow is different for different distance from the centre of cylinder. Therefore it will require integration.
Consider a cylinder of radius x$\pmb x$ from the centre of hollow cylinder, its AREA=2πxl$\pmb {2\pi xl}$( this is perpendicular to current flow)
Consider a width dx$\pmb {dx}$ along x$\pmb x $, this will be along the flow of current hence this will be the length of small elememtalelemental part considered .
Now consider infinite such cylinders from a to b$\pmb a \ to \ \pmb b$ each of length dx$\pmb {dx} $ . All these cylinders will be in series. Hence $$R = \int_a^b dR = \int_a^b\frac{p dx }{2πxl} =\frac{p ln \frac ba}{2πl}$$
Hope it clears your doubt , try using this concept for finding resistance of a cuboid along different edge lengths .
As to your second question - it can be done similarly by considering that the potential difference is applied across diametrically oppsiteopposite ends of sphere,
The area perpendicular to current can be taken as circular plate having width** dr**width $\pmb {dr}$, and then integrating along the diametric length. I leave it upto you to try the integration for this.
Kindly upvote my answer if it satisfies your doubt.