oh, fun! I've been to both Spain and Portugal on three separate trips so I can give some recs. How much walking energy do the kids have?
I went for a 7 day trip to Portugal and did: a day in Lisbon, a day in Sintra, a day in Marvao (tiny fortified town near Spanish border), 2 days in Porto (with a train ride on the tracks down the river Douro), a day back in Lisbon again (focusing on the Belem, with pastries and the Jeronimos monastery), and then back to US.
On my more recent trip to Spain I went to Granada and Madrid. Granada is amazing and you must go to see the Alhambra. In Madrid we went to a bunch of museums, but we also did a day trip to Toledo that I think would be fun for kids.
Personally I'm not sure driving is the best way to go in either country--lots of fast and clean trains/public transport in Spain and Portugal, and I remember the parking situation in Madrid being utterly miserable. But if you have a big group then trains start to get a bit expensive.
Honestly I struggled with food in both countries, as a vegetarian, though both Madrid and Lisbon have vegetarian buffet restaurants like this one: https://www.tripadvisor.com/Sh.....Terra-Lisb
I mostly ended up eating eggs and potatoes in both countries. If you don't eat eggs it will be extremely difficult. Probably best to hit up local supermarkets and buy your own food before going to smaller towns and locales.