Movistar, Vodafone and Orange are the operators that currently offer the iPhone in Spain. The newer versions like the iPhone 4 and 4S can be obtained for a contract for a minimum of 18 months and a data plan starting at 15 Euros per month. The voice plan depends on the number of calls you make. These models cannot generally be obtained for free unless you are a new customer and get the higher plans. This used to be easier until about six months ago when the operators seem to have gotten together and agreed not to give it out for free just to steal customers from one another. Now they cost in the area of 200 euros for a new contract and you can exchange your earned points if you continue with your existing operator. I don't know if pay as you go plans give you points, though.
I do suggest that you call the local head of marketing of the operator of your choice and pressure them into giving it to you for free. You might not entirely succeed but will probably get a very good price. (I got mine for 60 Euros and a friend got it for 35 Euros). Keep in mind that an unlocked newer version costs in the ares of 700 euros. The people in the shops are not empowered to give you these discounts. You need to contact the marketing people by phone.
The older versions, 3 and 3GS can be obtained for free with all three operators but the newer versions have more features. It depends what you want to get out of the smartphone but if it is only to use as a phone and do email and some web browsing, the older versions are quite good at this. My first iPhone was a 3G and now I have a 4. The 4 has a better camera and I do like to take pictures. The 4S has an even better camera but I have to wait until August when my 18-month period expires.
As to the difference with the Samsung Galaxy, I cannot help you there as I could only speak from hearsay. Perhaps someone else is in a better position. I can say though that I am happy with both my iPhone and iPad.