In the movie Glass, Elijah seems to be able to go in and out of his cell freely, I think he explains it at some point but speaking it very fast and since English isn't my native language I couldn't understand. How did he manage to do that?
We don't know.
The first time he left his cell, one of the orderly's had left it open.
- Hey, my man. How'd you get out of your room?
- You must have left the door ajar. He rolled out toward the noise.
At this point, Glass switches the pills so that he will no longer be under heavy sedation. From then on, he escapes his room a couple of times, but it is never explained how. There are multiple options.
When they first brought him here, he memorized a blueprint left out from an electrician and short-circuited the power to the whole hospital.
One is him somehow hot-wiring the door circuitry. Another is a stolen key-card. It is not explained in the movie, but the viewer is supposed to interpret his escapes as being due to his massive intelligence.
The CinemaSins youtube channels considers the "door ajar" explanation to be a big plot hole.
It is never fully explained how Elijah had been able to initially escape from his room, other than to show that he had been swapping his sedatives for aspirin that he had stolen.
Staple explains early in the movie that Elijah had managed to get a glimpse of the architectural blueprints of the building and almost manufacture an escape once before, so I think that it is assumed he simply figured out another way to get out of his locked cell considering that he hadn't been under sedation for some time.
It also makes clear that Elijah had been coming and going from his cell multiple times before, as he knew the comings and goings of the orderlies, so him speaking with Patricia was not the first instance of him escaping.