Hi Mandy. Your question has made me realise that this is not something I've covered in my site's "Living in Tenerife" page, so I'll amend the page to rectify that. I've checked and, unfortunately, it appears that you have to just turn up and queue. A useful webpage I've found is:
https://www.justlanded.com/english/Spain/Spain-Guide/Visas-Permits/Social-security-number