With four days and no car I would do two day trips at most, and keep two days for the city. My picks: Caminito del Rey for the cliff walk – book well ahead, it sells out – and Ronda for the gorge and the drive up through the Serranía. Both are easy by train or coach.
Nerja and Frigiliana make a gentler half or full day if you want coast rather than hiking. Granada is superb but it is a long day by bus and the Alhambra needs its own advance ticket, so it only works if you are willing to build the day around that slot. Córdoba is better as an overnight than a rushed day trip.
The one I would gently push back on is Gibraltar – the queue at the border and the crowds on the Rock can eat the day, and it is a marmite experience. Our
day trips from Málaga guide sorts them by how much day you actually have. Are you set on hiking, or more culture and views?