The cameras we have today are pretty smart, but light can be difficult to figure out and even the latest technology still makes mistakes. When your photos are coming out too light or dark, use a technique called exposure compensation to make correct exposures.
Check your digital camera for an "EV range" that looks like -2..-1..0..+1..+2. You may find it in a few places: in the viewfinder, on the LCD, or on a dial. High-end cameras might have a wider range, like -3 to +3, or even -5 to +5. Whatever the numbers are, think of each value in the range as a brightness value from dark (negative) to bright (positive):
When you apply these "brightness levels" to an actual scene, things start to make sense. Negative values make the image darker, and positive values make the image brighter.
When do you need Exposure Compensation?
A tricky lighting situation is one that fools the camera into thinking things are darker (or brighter) than they actually are. Imagine photographing someone in a black suit, standing in front of a black car, at noon. Your camera might see all the dark tones in this scene and think "hey, it's night, I should make this scene really bright". Then you end up with a not-so-black suit, car, and a white, blown-out sky.
How do you use it?
The way to compensate with EV is to think about how far in one direction you believe the camera has erred, and choose the opposite setting on the other side of the scale. If you think the scene is "one stop too dark" then the camera is trying to expose at -1, so you should dial in +1 EV. If you think it's "two stops too bright" then the camera is at +2, so you should dial in -2.
By the way, a "stop" is something like a unit of measurement for light. If you want to get scientific then read about F-numbers on Wikipedia. Better photographers can probably think about that kind of thing on the fly, but my thought process is more like "eh, this scene is a little bright, dial in -1/3" or "whoa, this is way too dark, dial in +2." You can practice by adjusting EV while in Live View and watching the brightness change on screen. And after shooting enough photos, you'll be able to eyeball everything.