I only travel in Europe away from the main heat/touristy season of Summer! DH and I have no children and equally enjoy walking, good food/wine and history. All my recommendations are pre-covid though, so prices/things etc might well have changed!
Where in Majorca are you thinking of staying? We stayed near Palma. There was a small gauge train from Palma to Soller. It was a lovely day out and we caught a local bus back to Palma as is was quicker. You can do the trip the other way around though. From my limited trip- more to see/do in Palma, but if its mainly beach you want then Soler might be better.
Malaga City. Not one of the many beachy, Brits-abroad, touristy places along the coast. It was 3 euro each bus trip from the airport to the 'city' and very easy to walk around the entire place. A mix of locals, Spanish, British, French and German tourists but also working 'city'. Very small in comparison to a 'city though'. More like a small town. There is a beach, castle, promenade to walk along, museums, lovely restaurants etc.
We last stayed at Santa Cruz apartments. Although we ate out most days, we have the option to cook in the apartment, which was right next to the most amazing markets. A day trip to Ronda by train was amazing too.
Madrid: Lots of museums and history. We walked everywhere. A day trip on Toledo was fantastic.