We did a 3.5 week trip with our 7 and 9 year old pre-Covid. Flew into Madrid for about a week, then bus to Grenada for 3 days, then bus to Nerja for 2 days, bus to Seville for 2 days, and train to Barcelona for about a week. It would have been nice to have a few more days in Seville. We got sunburned the first day in Nerja so 2 days was enough. We visited a lot of playgrounds, both little ones in a square as we walked by and also a few on purpose. We didn't do as many of the big sights. We had days with a museum or cathedral and days with other things like parks, beaches, countryside, and festivals. We liked climbing towers to see the views and walking through narrow streets and stopping at bakeries.
Madrid had a book festival in June, which ended the day we arrived. We tried, but were too jet lagged to appreciate it. We rowed at Retiro Park and went to the playground there, as well as going to a large, wooden beam playground and splash pad near a river another day. The Prado museum had a scavenger hunt handout for kids and we had looked at Art Detective books previously - they have pictures of famous paintings in one section and then "forgeries" in another section and you spot the differences and one kid was excited to look for pictures she knew; still we were only there for a few hours. We took a day trip to Segovia and were impressed by the aquaduct and alcazar. The archaeology museum was also interesting for a couple of hours; there was an area in front of the main museum to walk into a reproduction of cave art.
Granada was mostly for the Alhambra, but we also took a van tour to a botanic garden in the Sierra Nevadas and saw an early flamenco show and walked around the old hillside.
In Seville, we went to the roof of the mushroom modern art (I can't remember the name properly), took a horse drawn carriage ride, and toured the cathedral to see the elaborate tomb of Christopher Columbus and climb up the tower.
There is a kids guidebook called Mission Barcelona: A scavenger hunt adventure. It has brief descriptions and then things to look for at various sites and along walks. We walked along La Rambla at least twice to interact with all the living statue buskers. We went to the beach to swim one day. There was a Catalan festival so we saw the giant puppets and a lacemaker and several human towers. Parc Guell was very crowded. We were all awed by Sagrada Familia, although the winding staircase down from the towers is kind of scary.
If you are comfortable with AirBnB or can find an apartment hotel, it is very nice to have a room for the kids and a kitchen for breakfast. The train had some tables for 4 people, which worked well for our long trip from Seville to Barcelona.