A goal counts only when the whole puck has crossed the whole goal line, between the posts and under the crossbar. The goal line is the red line running across the ice at the front of the net, and the net sits on it. Because a puck is small and moves fast, a puck that only touches the line, or hits the post and stays out, is not a goal and play simply continues.
For shooters, the lesson is to keep playing until you hear the whistle, because a shot that does not go in can still produce a rebound. For goalies and defenders, it means never giving up on a puck that is close to the line. Parents watching close calls should know that officials judge whether the whole puck crossed the whole line, and that the way close plays are checked can differ by league and age level.