Yes, it could have. Fanfiction often takes existing universes and expands or reimagines them. Harry Potter has so many elements that could potentially be the work of a fan. For example, the magical world with its unique creatures, spells, and Hogwarts as a school. If J.K. Rowling wasn't the original creator but was building on someone else's initial ideas about a magical school and a boy wizard, it would be fanfiction. However, she is the original creator, but the conceptually it has elements that could be seen in a fan - created work.
A total of seven Harry Potter novels have been written. The series includes 'Harry Potter and the Philosopher's Stone', 'Harry Potter and the Chamber of Secrets', 'Harry Potter and the Prisoner of Azkaban', 'Harry Potter and the Goblet of Fire', 'Harry Potter and the Order of the Phoenix', 'Harry Potter and the Half-Blood Prince', and 'Harry Potter and the Deathly Hallows'.
There are seven novels in the Harry Potter series: Harry Potter and the Sorcerer's Stone, Harry Potter and the Chamber of Secrets, Harry Potter and the Prisoner of Azkaban, Harry Potter and the Goblet of Fire, Harry Potter and the Order of the Phoenix, Harry Potter and the Half-Blood Prince, and Harry Potter and the Deathly Hallows.
Seven Harry Potter novels have been adapted into movies: Harry Potter and the Sorcerer's Stone, Harry Potter and the Chamber of Secrets, Harry Potter and the Prisoner of Azkaban, Harry Potter and the Goblet of Fire, Harry Potter and the Order of the Phoenix, Harry Potter and the Half-Blood Prince, and Harry Potter and the Deathly Hallows.
One possibility could be a world where Harry Potter takes on Voldemort's role in terms of power. The wizarding world would be in chaos as Harry, with his different values from Voldemort, tries to enforce his own version of order. He might use his knowledge of good magic in a twisted way, believing he is doing the right thing for the greater good. For example, he could start controlling the Ministry of Magic to implement changes he thinks are necessary, but which others may see as tyrannical.