Within a few hours of learning they could use the Force,
Rey is using Jedi mind tricks to escape her cell.
Some Jedi take months and years to master Jedi mind trick. How is that possible to figure it out so quickly?
The Alan Dean Foster novelization doesn't offer a clear answer (proper answer is of course "because she is the Shiny New Hero", with subtext of "we are lazy as screenwriters"), but offers some more clarity.
She guessed she would be able to do this because she accidentally pushed Kylo Ren out of her mind and invaded his right before
It took her a couple of tries to succeed. It wasn't quite "instant", though not exactly "years".
If she could push [Kylo Ren] out of her mind and enter his, what else could she do? What might she be able to do with regard to someone else? Someone less skilled, untrained in the ways of the Force? The single guard posted just inside the front of her cell, for example?
He turned toward her, patently unconcerned and not a little bored. She studied him closely. As he was about to speak, she addressed him clearly and firmly—and not only with her voice.
“You will remove these restraints. And you will leave this cell, with the door open, and retire to your living quarters.”
The guard eyed her silently. He did not look in the least intimidated. Her confidence wavering as she shifted slightly in her bonds, she repeated what she had said with as much authority as she could muster.
You will remove these restraints. And you will leave this cell, with the door open, and retire to your living quarters. You will speak of this encounter to no one.”
Raising the heavy, black-and-white rifle he held, he came toward her. Heart pounding, she watched him approach. Was she going to be killed, freed, or maybe laughed at? Halting before her, he looked down into her eyes. When he spoke again, there was a notable alteration in his voice. It was significantly less confrontational and—distant.
“I will remove these restraints. And leave this cell, with the door open, and retire to my living quarters. I will speak of this encounter to no one.”
Please note that years of Jedi training are not always necessary for someone to access their Force abilities:
Anakin accessed the Force precognition as a pre-teen while Podracing
Luke tapped into the Force to fire his weapons to destroy Death Star after an incredibly short stint of training with Obi-Wan on board Millenium Falcon, where he never trained to aim with the Force
EU/Legends canon is replete with similar cases (Corran Horn, Kyp Durron are 2 that instantly come to mind)