Nezuko became a demon when Muzan Kibutsuji, the King of Demons, attacked and slaughtered her family, turning her into a demon during the incident. Despite being transformed, she retained some human emotions and thoughts, which is unusual for demons. This transformation was part of Muzan's efforts to create demons with powers he sought, including immunity to sunlight, a rare trait Nezuko eventually developed. Muzan had attacked the Kamado family possibly because of their connection to Yoriichi Tsukiguni, a master of the Sun Breathing style, which was a threat to him. Nezuko's transformation was also unique because she received a high amount of Muzan's blood, making her powers and growth rate extraordinary compared to typical newly turned demons.
Additionally, it is implied that Muzan may have tried to turn the whole family into demons, but only Nezuko's body could handle it, and she was determined to survive for her brother Tanjiro, which helped her persist as a demon with retained human traits.