Perhaps you previously assigned some value to g.
Try
?g
and see what Mathematica has been told about g.
Or click Evaluation on the menu bar, then Quit the Kernel, then Local, then Quit and that should forget any prior assignments. Try your g[x_]:=x^2;g[2] after that.
Note: Sometimes Mathematica will consider two thing next to each other, sometimes even on two adjacent lines, as being multiplied together. Using semicolons to separate things will tell Mathematica those are two separate things and not to be multiplied.