Well, it might be that in a situation where he is in danger. Maybe some dark magic object made of metal is about to attack him, and in a moment of self - defense, his latent ability to control magnetism emerges. He feels a strange connection with the object and manages to stop it in mid - air by using this new - found power.
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.
He could use it to unlock metal locks without a key. Just by using his magnetism control, he can manipulate the tumblers inside the lock.
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.
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.
Maybe he discovers it during a particularly intense storm at Hogwarts. He could be in a dangerous situation, like being chased by some dark creatures, and in a moment of desperation, he unknowingly summons lightning to protect himself.
It could be through some kind of inheritance. Perhaps he has some long - lost family connection that gives him this unique power. In the fanfiction, he might start noticing strange things happening around cold or icy elements, and then gradually realize that he can actually control them.
In some versions of the fanfiction, it could be due to his unique heritage. Since Harry has a complex family background in the wizarding world, there might be some long - forgotten blood magic in his lineage that surfaces unexpectedly. One day, during a duel where he gets a minor cut and his own blood is exposed, he notices that he can somehow manipulate the flow of blood, and that's how he discovers this ability.
Perhaps it is related to some old magic that he inherits. One day, when he is exploring an old, abandoned place like an ancient wizard's tower. There, he touches an old relic which activates this hidden ability. As soon as he touches it, he feels a strange connection with the shadows around him and realizes he can control them.
In some fanfictions, it could be through a moment of extreme danger or intense emotion. For example, he might be in a situation where his friends are in peril from a fire - based threat. His strong desire to protect them could trigger this hidden ability. It's like a latent power that surfaces when his will is at its strongest.
In some fanfictions, it could be during a moment of extreme danger or intense emotion. For example, he might be facing a powerful dark wizard and in a desperate attempt to defend himself, he unknowingly channels lightning. It could also be through some kind of ancient magic that he stumbles upon, perhaps while exploring a hidden part of Hogwarts. Another possibility is that it is a latent ability that is awakened by a powerful magical artifact that he comes into contact with.