The container keeps necessary information internally for direct access to elements as the internal implementation of deque is basically a double ended queue of chunks(vectors). Each chunks has elements indexed,once the chunk is full,another chunk is added maintaining the integrity of indexing and the container class keeps information it needs to provide access,locating the correct chunk and thereafter the indexed location of the element sought.
You can read the great article here which would provide all the knowledge you seek and even more than what you seek:
https://www.codeproject.com/Articles/5425/An-In-Depth-Study-of-the-STL-Deque-Container
Also to see a brief implementation of deque,you can go through the accepted answer on stack overflow
What really is a deque in STL?