All pushbuttons have something called "contact bounce". When you press down a button, the mechanical parts bounce up and down and generate an electrical disturbance for a short time. Connect an oscilloscope to any button and check, you will see a short sine wave when it is pressed.
Another issue is electro-magnetical interference (EMI), "glitches" that are caused by noisy electronics. Such glitches can be removed through hardware with decoupling capacitors etc, but a serious embedded software designer will still have glitches in mind when writing the program.
Because of the two issues above, you must "debounce" a button whenever you read its status.
This is typically done this way:
1) Set an interrupt on the port where the button is connected, or alternatively read ("poll") the port from the main program.
2) When the port goes active, you have either found a user pressing the button, or a contact bounce from a previous button press, or an EMI glitch. You don't know which.
3) Start a timer. 5ms is a good timer value. During this time, ignore the button port.
3) When the timer has elapsed, read the port again.
4) Make sure that the values are the same during the 1st and the 2nd read. If they aren't, disregard the whole keypress - it was likely caused by EMI.
5) If the values were the same, light the LED etc.