Thousands of people gathered in Madrid to protest against NATO just days before the alliance is due to hold a summit in the Spanish capital.