Talking about Rey, if you remember, she'd already dreamed about where Luke was - Ren pulled it out during the interrogation, and that's when she was able to block him. Ren said something about her going there in her dreams as a safe place -- so, she already had a connection to Luke.
So, two random possibilities -- 1) she may have picked up what was possible with the Force when she got into Kylo Ren's head, which he inadvertantly showed her how to do and 2) possibly Luke was training her without her conscious awareness when she visited the island in her dreams.
So, two random possibilities -- 1) she may have picked up what was possible with the Force when she got into Kylo Ren's head, which he inadvertantly showed her how to do and 2) possibly Luke was training her without her conscious awareness when she visited the island in her dreams.