If you book the flight as CAI-MAD then you get the miles for the direct distance CAI-MAD but it only counts as one flight segment (out of the maximum 20 allowed) on your ticket.
If you book it as CAI-BCN-MAD then you get the miles for the two segments separately, but it counts as two segments towards your 20-segment limit. (And, of course, you may spend some time in Barcelona)