What we want to do is pressure and contain the attack, slowing them down and forcing them to one side away from the goal. Remember, the sideline is a defender's teammate. If you can direct an attack toward the side and contain it, there's a good chance the ball will be turned over out of bounds. Otherwise the attacker might have to stop and pass back, or the attacker will make a bad touch and we could win the ball. Either of those three scenarios is a defensive win. Don't try to take the ball unless the attacker makes a bad touch and the ball is loose! The defender MUST be patient in this situation and remember that his job is not to tackle the ball every time, but rather to slow the attack, direct it away from the goal and pressure the attacker into making a bad play or pass back.
Here are a couple of great videos that highlight the problem and demonstrate how to properly defend in these situations.