Starting the process can be done from Spain. You just need to return to the US to pickup your visa and re-enter the country on it as such. The whole process will probably take 3-4 months I’d estimate.
Marrying your Spanish girlfriend may have other benefits, however it’s also not a small commitment either.
I would go with the visa process as it would probably be quicker. I could be wrong but I know in other EU countries, you have to be living there legally to get married (which depending on how strict they are, could include a 3 month stay back in the US) and the process involved with getting paperwork before and after is not any easier or faster.