If you invest in a Spanish residence permit by purchasing a property but stay in your home country, you will need a Spanish visa to enter the country. Immigration authorities issue a Golden Visa for foreign investors which allows them to stay in Spain for six months or a year depending on whether you have already made an investment or not. As a rule, this visa gives you enough time to buy your property and get a residence permit that allows you to stay in Spain for two years and then extend it for another five years.
So, a Spanish Golden Visa is
a relatively quick way to get a prestigious status of an investor compared to a traditional route via Spanish visa centres in your home country;
a visa in your passport to enter Spain, enrol biometrics and get a residence permit.
If you invest in a property while living in Spain, e.g. as a migrant worker, you can apply for a residence permit without getting a Golden Visa.