The most common method of ransomware infection is through a "Remote Desktop" connection. This is not available by default and is usually associated with people who work remotely. In other words, one has to activate the feature for it to be running on a computer. There are ways to mitigate such risk but this is still the most common means of infection. They will hack in to a computer through this feature and install a program on the computer to start the encryption process, and can also encrypt the files on other computers to which the infected computer is connected and has permissions.
Another way to get infected is to open a malicious attachment in an email. It can be a Word document or any other type of file that can contain and execute a payload (Word, Excel and the like can execute code via built-in macros.) This can install the same program as would be installed via a hacked Remote Desktop described above. This means of infection is far less common than Remote Desktop, but it happens.
Another way to get a malicious program on your computer is to go to a website that pushes a file to you in a way that induces you to "open it" (actually, you're running it.) What you're running is actually the encryption program.
What you experienced is different than this. Your experience, with the phone number to call on the screen, is the same M.O. as the calls people get on their phones from "Microsoft Support" (always with a thick indian accent) claiming that they have been alerted that your computer "is infected!!!111!" All of those are just basic scams to scare you into paying them money for software you don't need or want. I've never seen any malicious payload left behind on a computer whose owner fell for one of those.