The rules have changed in 2020, see Schengen visa(s) for two events close in time for more details
It's difficult to find clear guidance on this as it is a somewhat unusual case. The criteria laid out in the relevant regulation are first and foremost intended to apply a single “visit” and it's not obvious whether several trips to different destinations within a short time frame should be considered as such.
If the whole journey is treated as a single trip, then it would make sense to apply to Spain (as the main destination). But I could also see why a consular officer could be reluctant to authorize what could also be seen as an entirely separate trip to another country.
Multiple-entry visas are not primarily intended for complex trips but to reduce the administrative burden created by multiple applications from trusted travellers who have good reasons to visit a member state repeatedly. Having used correctly several visas from the same consulate before further heightens your chances of receiving such a visa. So if you have business associates or relatives in one of these countries and you have been there before, it might make sense to try that country first.
Note that no matter what you do, applying to the wrong consulate is not a valid ground to refuse a visa. What could happen is that you receive a single entry visa just for this one trip and are forced to apply again to another consulate. Alternatively, if the consulate declines to process your application and think you should apply to another member state, they should inform you quickly and refund the fee. This would not be treated like a negative decision (which would mean losing your money and having a black mark on your record).