I am in the process of learning how to use the ESP8266. For my particular task I need this module to operate in a mesh network topology. I don't know how much you know about networking and wireless communication, so I'm going to describe as much as I can remember, as simply as I can, and hopefully I will answer at least some of your questions. What I know so far:
The ESP8266 does not support ad hoc mode with all its perks (self healing, self organizing, etc) so making it a part of a mesh network requires one to write firmware that uses the AP and STA modes.
Access Point (AP) mode allows the ESP8266 to function as a router, broadcasting its SSID across the wireless 2.4GHz spectrum. ESP8266 has inbuilt TCP/IP and all of the neat features (like DHCP and DNS) one would need to get things started. So as soon as a device connects to your ESP in AP mode it will be assigned a local IP address. This mode is useful if you want to create a closed network for communication between devices, without access to the internet (or with, but then you'll have a router and will need more hardware).
Station mode (STA) basically makes the ESP8266 into a client, making it able to connect to other wireless networks (APs). This is the mode that allows one to use the ESP in IoT projects. So you basically connect to a network, get assigned a local IP by the router, create a server and listen on some port. After that you can send messages (HTTP requests) to the ESP from any device in the same network, or with further tweaking - from the internet.
As mentioned, to do all this one needs to have a TCP/UDP server running on the ESP8266. Luckily to create a server and make it listen to a port only takes 2 lines of code - courtesy of Arduino WiFi Shield and good people who tweaked it for ESP8266. Or you can do it the old fashioned way by writing AT commands (also really easy tbh).
If you want your ESP to be able to connect to other devices on the network/internet, you will need to establish a connection to the devices IP address, in effect making your ESP module a TCP/UDP client.
ESP8266 can be in AT and STA modes at the same time, while also running a server and being a client. If using AT commands, I believe one is limited to 5 TCP/UDP connections, however I know some people managed to change that to 256 by doing some wodoo magic.
Hope this helps in your ESP endeavors
PS: I am a little bit of a noob, so take what I've written with a grain of salt