That's one of those tropes where fanon has kind of smoothed out the rough edges of canon, right? In the books, Snape's expertise is potions and occlumency, not subtle observation of child welfare. So, authors get creative.
One common thread is accidental magic or a failed occlumency lesson. Harry's occlumency shields are notoriously bad, and during a particularly intense session, Snape might glimpse a memory of the Dursleys' treatment—Petunia swinging a frying pan, Uncle Vernon shouting, the cupboard. Snape's expression just… freezes. He ends the lesson abruptly, and he never brings it up directly, but his behavior shifts in tiny, sharp ways afterward.
Another route is through potions or magical scans. A diagnostic charm in the Hospital Wing, maybe after a Quidditch injury, reveals chronic malnutrition or old, poorly healed fractures. Madame Pomfrey might be bound by confidentiality, but Snape is there brewing the necessary potions. He'd see the prescription and put the pieces together himself. It's quieter than a dramatic confrontation, which fits his character more.
I've always preferred the subtle takes where he knows but does nothing overt, just brews a nutrient potion and slides it into Harry's morning pumpkin juice without a word. The denial of any caring intention feels truer to him than a big emotional scene.