How to get research opportunities?

Hi everyone. So I am reading through all these threads and everyone seems to be having research experience and opportunities, I am wondering how everyone was able to do this. Are you just emailing professors and asking to intern through their lab or is it something else?
Thanks