The formats for telephone numbers are specified by the International Telecommunications Union, and the full number is composed of:
– access code (national or international, usually 0 and 00 respectively although in the US it’s 1 and 011)
– country code (generally starting with a 1 for north american locations, 2 for africa, 3 or 4 for europe, ...)
– area code (usually 2–5 digits, for geographic numbers this is usually a specific geographic location)
– local number (the first few digits usually define a particular exchange)
In general if calling within an area you don’t need to use the area code you just dial the local number, similarly calling within a country you don’t need the country code just area+local.
For mobile phones and other non-geographic numbers the area codes are usually grouped by operator or type of service rather than geographic locations. Number portability means that numbers can be ported from one operator to another, or from one geographic location to another, however so area codes are reliable indicators of location or operator.
The country codes and overall format are specified by the ITU, individual countries determine their own access code, area code format, and assign area codes (though the ITU make strong recommendations in these areas), and it’s generally up to individual operators how area codes are broken down locally (though this varies from one country to another and is usually legislated on at a national level to some extent)