When do I have to report a gain from a investment?

Why do I have to report my gain to the IRS, when I didn't withdraw from my account?