When a person gets into somewhere that they're not supposed to be able to get into, you can say that they've "gained access" to it. For example:
The police have not been able to determine exactly how the thieves gained access to the building.
If someone were to break into your email account, they'd be able to gain access to your bank accounts and other systems as well.
Someone "gaining access" is usually frightening and bad. If someone is allowed to get into somewhere, you usually saay that they "got access" or "have access":
How do I get access to the shared drive?