We’ll probably never know.
My own guess would be that was the biggest crime young Jim had committed at the time, so he paid extra attention to whether anyone suspected Carl’s death was murder rather than an accident. Somehow Jim must’ve seen or heard about Sherlock’s investigation or attempts to convince the police. I can imagine a few ways that could’ve happened, but we’re basically in fanfiction territory there. So your guess is as good as mine.
I think it’s more likely the Carl Powers case was just the first time Sherlock came to Jim’s attention.
Jim already knew about Sherlock’s investigation of the Carl Powers case in The Great Game. That’s why he incorporated Carl’s shoes into one of the puzzles.
There’s nothing to suggest Jim and Mycroft had ever discussed Sherlock’s history at that point. As Mycroft later explained, he only told Jim about Sherlock’s life because it seemed like a way to get Jim to talk about the key code when Mycroft had him in custody. Mycroft didn’t have Jim in custody until after Scandal.
Irene: Jim Moriarty sends his love.
Mycroft: Yes, he’s been in touch. Seems desperate for my attention, which I’m sure can be arranged.
The Great Game:
Man (speaking for Jim): Clever you. Guessing about Carl Powers. I never liked him. Carl laughed at me, so I stopped him laughing.
John: Anything on the Carl Powers case?
Sherlock: Nothing. All the living classmates check out spotless, no connection.
John: Maybe the killer was older than Carl?
Sherlock: The thought had occurred.
John (speaking for Jim): Nice touch, this. The pool, where little Carl died. I stopped him. I can stop John Watson, too. Stop his heart.
So Jim definitely killed Carl. Jim wasn’t a classmate of Carl’s, but was probably close to the same age based on the comment about Carl laughing at him.