At least 50 people were injured after several fireworks exploded among a crowd at a festival in northern Spain.