Here's what I would do.
If your starting point is the US (as mine is), I'd stay at least 2 weeks; In my experience, it's not worth travelling to Europe from the US for a vacation with a kid for less time than that -- too much travel time and jet lag, not enough fun (mine is now a tween, but we've been doing this since he was 18 months old and have 4 trips under our belts, so a trip every 2 or 3 years). Of course if you are, e.g., like your namesake in the UK, then you can ignore this bit.
No way would I rent a car.
I've spent (vacation) time in Madrid, Barcelona, and Granada (but I hear Seville and several other southern destinations are lovely). Honestly, I personally might do just a week in Madrid and a week in Barcelona. My recollection of how we traveled (Madrid --> Granada --> Barcelona) when I did this is that it involved overnight trains, but looking at schedules I'm not sure how that was possible. But if you can work it out, and assuming your kid is a decent sleeper, it's a fun way to cover ground. Of course, space in a sleeper compartment adds to the cost (and is well worth that cost, with a kid), but not absurdly. I'd price Eurail passes (assuming you are traveling on a US passport), and direct tickets as well.
I'd rent apartments (was easily able to do this in Hungary and Croatia via the internet, VRBO and/or Homeaway last summer, can't imagine Spain would prove more difficult than those places). For meals, my recollection is that Spanish breakfasts are utterly delicious and very affordable, ditto lunches. With a kid I'd do tapas and/or cook at home for dinners, as Spanish restaurants really do serve very, very late -- I remember showing up at restaurants at 8 p.m. and have the servers seem perplexed as to what we were doing there so early (and food was not prompt in showing up). Buy food in markets or grocery stores and do (some of) your own food prep. Europe has wonderful breads and yogurts, just to name a couple of things. Pack some tupperware, so you can take food with you readily for picnics and such. Ziplock bags are also really useful.
When my kid was your kid's age, I had a peanut shell sling (kid carrier, you can google it) and carted him on my hip that way good distances. But mine's a scrawny one -- he weighed at most 40 lbs. at that age, and maybe less -- YMMV. I'd recommend a Safe Rider travel vest (again, you can google it) over a carseat, unless you're going to rent a car (but don't rent a car), just to use in the occasional cab and such.