It's possible that through his unique connection with Voldemort. Since they were so closely linked, and Voldemort was always obsessed with cheating death, Harry might have gained the ability to control death as a sort of counterbalance to Voldemort's attempts.
Perhaps his own near - death experiences. Harry has had several brushes with death throughout the series. These experiences could have somehow unlocked within him the latent ability to control death, like a transformation that occurs after facing death so many times.
In some fanfictions, it could be through intense magical training and study. Maybe he discovers an ancient spell or a hidden magical technique that allows him to assert control over the dangerous Fiendfire.
Well, it might be related to his connection with the Dark Lord. Since Voldemort was able to control the basilisk before, and Harry has a unique connection to Voldemort through the scar. This connection could be manipulated in some way in the fanfiction, allowing Harry to take over the control of the basilisk from Voldemort.
In some fanfictions, Harry might gain the ability to control Fiendfyre through intense magical training. He could be mentored by a powerful wizard who teaches him the dark arts in a controlled way, allowing him to master Fiendfyre. Another possibility is that he inherits some ancient magic that gives him this power. For example, if he discovers a long - lost family heirloom that has the magic to control such dangerous spells.
It could also be due to his own inner strength and growth as a wizard. Harry has faced so many challenges and traumas throughout his life. His experiences might have awakened a latent power within him that allows him to control dementors. His strong willpower and determination, which have been developed over years of fighting against the dark forces, could be the key factor in this newfound ability.
Well, in some fanfictions, Harry might gain control over the Wizengamot through his heroic deeds. For example, if he saves the wizarding world from a great threat again, the public support could be so strong that he can influence the Wizengamot's decisions. He could also use his knowledge of magic, especially some ancient or powerful magic that gives him an edge in the political arena of the wizarding world.
Maybe he accidentally finds out when he is near some magnetic objects in Hogwarts. For example, he might notice that he can make the metal keys move towards him without using magic spells he already knew. It could be during a time when he is exploring an old, forgotten part of the castle where there are a lot of metal objects and strange magnetic fields.
In some fanfictions, it could be through an accidental encounter. Maybe he was in a situation where metal objects started to react to him unexpectedly, like when he was near a bunch of keys and they suddenly started to move towards him. This made him realize that he had this strange new power.
Perhaps he has a strange dream where he's in a world made entirely of shadows and he can manipulate them freely. When he wakes up, he starts to experiment and finds out that he can actually do the same in the real world. He might start with small things like making the shadow of a quill move on his desk, and gradually discovers the full extent of his power.
Well, it might develop as a result of some new magic he encounters. There could be an ancient spell or a magical artifact that gives him the power to control sand. He then has to figure out how to use it. He may start with simple things like making sand swirl around his hand, and as he gets more used to it, he can do more complex things like creating sand barriers or even using the sand to communicate in some way.
Perhaps it's through an accidental encounter with a powerful magical plant. He tries to interact with it in a normal way but ends up influencing its growth and behavior. This unexpected event makes him aware of his unique power to control nature. For example, he might touch a withering plant and suddenly it springs back to life and starts to grow rapidly under his touch.