Please, please, please remove the line "Maybe in some cases you punish it if it doesn't do what it's supposed to do." Please don't promulgate this dangerous misconception. Training is encouraging a behavior, and there are 2 ways to do it.
Notice that in negative reinforcement, the reward takes place after the behavior has already happened. Also notice that in negative reinforcement, you are encouraging the subject to do the behavior more, not stop the behavior. A classic example of negative reinforcement has a constantly electrified floor, and when you see the desired behavior, you turn the electricity off. You don't turn on the electricity if you don't get what you want, you turn the electricity off when you do get what you want.
Can you see the difference between negative reinforcement and punishment now? Negative reinforcement is a training technique that encourages a behavior. Punishment is not a training technique, and can never successfully make a behavior occur, nor encourage more of a behavior.