A factory where a shelter collapsed earlier this week injuring 23 people was making clothes for Swedish fashion retailer H&M without its knowledge, the company has admitted.