You can pre-register with both, meaning that you can register on a certain date, and indicate that you´ll start your trading or activities at a later date. The latter date must correspond though with both agencies. Pre-registering with Hacienda will enable you to deduct expenses for the start up of a business, building works etc. as of the date you do so.
The date you indicate as your startdate with bth Haciena, the Tax Office and the Seguridad Social will then count as your official startdate and your Autonomo contributions will be calculated as of that day.
The Seguridad Social registration needs to be done telematically, with a digital certificate installed on your computer and you will need the ´epígrafe´ the tax code for your activity, that you also used to register with Hacienda. And while you fill out the forms for Seguridad Social online, at one time they will seek confirmation from Hacienda that you have indeed registered with the same ´epígrafe´ there, so it makes sense to do the Tax Office pre-registration first, Seguridad Social second.
If you don´t match the actual startdates it can mean that the Seguridad Social will take the full month´s payment for the first month, instead of the pro rata amount, and deny access to the Tarifa Plana, for example.