I do not have children, so my opinions about what might appeal to young children are worth less than zero.
I agree with Jules; the heat in Andalucia would eliminate Option 1 for me. Remember that Madrid itself will probably be seriously hot, just not quite as intolerable as Andalucia. I think 3 scorching cities is way too many. And none of them have beaches.
Zaragoza is, unfortunately, also a very risky summer destination. Check its weather stats. I would describe my 2016 experience there (I think it was July) as "oppressive".
Valencia was pleasant in early May, but to me it's not one of Spain's most distinctive cities. However, it may have sights appealing to your kids (the aquarium is quite expensive, though), and the weather may be tolerable in the summer. I haven't checked that data. And it's on the coast, so there would be beach possibilities.
I really like the small regional capital of Teruel, which is on the secondary rail line between Valencia and Zaragoza, but it, too, is likely to be frightfully hot in the summer. And it's really too long as a day-trip from either direction. But the mudejar towers are really neat. Maybe on a later trip you can see Teruel and Albarracin.
Cuenca's on the AVE line between Madrid and Valencia. It has a bit of elevation so is probably not quite as hot as Madrid (but I haven't verified that supposition).
There are lots of possible day-trips from Barcelona. My favorite is Girona. The Dali Theatre and Museum in Figueres is weird enough that it might appeal to kids. That's doable as a day-trip if you don't mind the train time and buy promo tickets on the AVE early. Figueres isn't terribly exciting aside from the Dali site. Besalu has a cool fortified bridge. I understand there's bus service from Barcelona to Besalu, but I traveled there while based in Girona, which made it a considerably shorter trip. Figueres is also faster and cheaper if you are based in Girona, so there's a lot to be said for spending some nights there.
There's also Montserrat, which would probably be cooler than Barcelona, with some walking/hiking opportunities. Of course there are beaches in Catalunya, but I don't know which ones would be the best family day-trips from Barcelona.
In the Basque Country, Hondarribia is fairly small and not as touristy as San Sebastian. It's on the coast practically on the French border. The three coastal towns of Zumaia, Getaria amd Zarautz can be combined into one day-trip; you can even walk one of the legs. Those are all former fishing villages now become tourist destinations. I remember seeing beaches. Otherwise, they seem to be just cute little places with restaurants.
The interior Basque capital of Vitoria-Gasteiz isn't super-small, but it doesn't seem to get many tourists. Its historic district is picturesquely situated on top of a hill; there are outdoor escalators to assist with the climb.